Ubuntu vsftpd安裝設(shè)置文件不是件困難的事
Ubuntu vsftpd對于電腦使用的玩家的常用軟件,然后我就學習及深入的研究Ubuntu vsftpd,在這里和大家一起探討Ubuntu vsftpd的使用方法,希望對大家有用。Ubuntu vsftpd 和Proftp 安裝與配置 ZT
1)安裝Ubuntu vsftpd
Ubuntu安裝軟件倒不是件困難的事,輸入:sudo apt-get install Ubuntu vsftpd可能會提示你使用光盤,放進去再按回車就行了。安裝了之后會在/home/下建立一個ftp目錄。這時候你可以試著訪問下ftp://IP地址。應(yīng)該可以看到一個空白內(nèi)容的ftp空間。默認設(shè)置下匿名用戶可以下載,但不能寫入或是上傳
2)設(shè)置 Ubuntu vsftpd.conf文件
現(xiàn)在我們要讓匿名用戶無法訪問,并且得輸入Linux上的用戶密碼后才能訪問到他們自己目錄里的內(nèi)容。首先找到設(shè)置Ubuntu vsftpd的文件,位置在/etc/ vsftpd.conf修改之前***先備份下這個文件:sudo cp /etc/ vsftpd.conf /etc/ vsftpd.conf.old然后可以改動了:
- #不讓匿名用戶使用
- #anonymous_enable=YES
- #本地用戶可用
- local_enable=YES
- #可用寫操作
- write_enable=YES
- #不需要顯示某目錄下文件信息
- #dirmessage_enable=YES
- #加點banner提示
- ftpd_banner=Hello~~
- #FTP服務(wù)器***承載用戶
- max_clients=100
- #限制每個IP的進程
- max_per_ip=5
- #***傳輸速率(b/s)
- local_max_rate=256000
- #隱藏帳號
- hide_ids=YES
好了,重啟下ftp 服務(wù)器看看效果重啟后還是和原來一樣對嗎?呵呵,這是默認的ftp目錄在做鬼,我們把它刪除,再看看。怎么樣?要你輸入用戶名和密碼了吧。
新的問題
1.輸入用戶名密碼后顯示的位置是在用戶的根目錄下,而我們的WEB內(nèi)容是在public_html目錄里
2.用戶可以跳到任何其他目錄(非常危險..)要解決這些問題我們還得設(shè)置下Ubuntu vsftpd.conf
- #啟動chroot列表(Change root)
- chroot_list_enable=YES
- #指定列表位置(我這用的是默認地址)
- chroot_list_file=/etc/Ubuntu vsftpd.chroot_list
- 接下來我們得在Ubuntu vsftpd.chroot_list上寫進去我們要限制哪些用戶,不讓他們“漂移”..
現(xiàn)在有用戶linyupark,所以只要sudo nano一下,往里面寫就行了這樣我們已經(jīng)解決第2個問題了,登陸的用戶只能在它的用戶文件夾里活動,下面我們要更狠一點,讓他只能在public_html里活動依然還是找Ubuntu vsftpd.conf
#這句默認設(shè)置里是沒有的,自己加user_config_dir=/etc/自己定義一個設(shè)置個別用戶用的文件夾地址根據(jù)自己設(shè)置的地址,建立一個相應(yīng)的文件夾,然后往里面建立和用戶名相同的文件,nano一下:#本地用戶的根地址,假設(shè)用戶是linyuparklocal_root=/home/linyupark/public_html好咯,重啟下服務(wù)器。
1- 使用下面的命令安裝proftpd:
- Code:
- sudo apt-get install proftpd
2- 在etc/shells 加入如下代碼 (sudo gedit /etc/shells to open the file)(譯注:命令行模式下sudo vi /etc/shells) :
- Code:
- /bin/false
新建一個 /home/FTP-shared 目錄 :
- Code:
- cd /home
- sudo mkdir FTP-shared
創(chuàng)建一個只能用來讀取ftp的用戶userftp. 這個用戶不需要有效的shell(更安全) ,所以選擇 /bin/false shell 給 userftp , /home/FTP-shared 作為主目錄。 為了是這部分更清楚,我給取此操作的命令行:
- Code:
- sudo useradd userftp -p your_password -d /home/FTP-shared -s /bin/false
- 在FTP-shared 目錄下新建一個download和一個upload 目錄:
- Code:
- cd /home/FTP-shared/
- sudo mkdir download
- sudo mkdir upload
現(xiàn)在我們來給它們設(shè)置相應(yīng)的權(quán)限:
- Code:
- cd /home
- sudo chmod 755 FTP-shared
- cd FTP-shared
- sudo chmod 755 download
- sudo chmod 777 upload
3- 好了,現(xiàn)在進入proftpd的配置文件:
Code: sudo gedit /etc/proftpd/proftpd.conf //特別注意路徑,網(wǎng)上以前給的是錯的當然你可以按你的需要編輯你自己的proftpd.conf:
- Code:
- # To really apply changes reload proftpd after modifications.
- AllowOverwrite on
- AuthAliasOnly on
- # Choose here the user alias you want !!!!
- UserAlias sauron userftp
- ServerName "ChezFrodon"
- ServerType standalone
- DeferWelcome on
- MultilineRFC2228 on
- DefaultServer on
- ShowSymlinks off
- TimeoutNoTransfer 600
- TimeoutStalled 100
- TimeoutIdle 2200
- DisplayFirstChdir .message
- ListOptions "-l"
- RequireValidShell off
- TimeoutLogin 20
- RootLogin off
- # It''s better for debug to create log files ;-)
- ExtendedLog /var/log/ftp.log
- TransferLog /var/log/xferlog
- SystemLog /var/log/syslog.log
- #DenyFilter \*.*/
- # I don''t choose to use /etc/ftpusers file (set inside the users you want to ban, not useful for me)
- UseFtpUsers off
- # Allow to restart a download
- AllowStoreRestart on
- # Port 21 is the standard FTP port, so don''t use it for security reasons (choose here the port you want)
- Port 1980
- # To prevent DoS attacks, set the maximum number of child processes
- # to 30. If you need to allow more than 30 concurrent connections
- # at once, simply increase this value. Note that this ONLY works
- # in standalone mode, in inetd mode you should use an inetd server
- # that allows you to limit maximum number of processes per service
- # (such as xinetd)
- MaxInstances 8
- # Set the user and group that the server normally runs at.
- User nobody
- Group nogroup
- # Umask 022 is a good standard umask to prevent new files and dirs
- # (second parm) from being group and world writable.
- Umask 022 022
- PersistentPasswd off
- MaxClients 8
- MaxClientsPerHost 8
- MaxClientsPerUser 8
- MaxHostsPerUser 8
- # Display a message after a successful login
- AccessGrantMsg "welcome !!!"
- # This message is displayed for each access good or not
- ServerIdent on "you''re at home"
- # Set /home/FTP-shared directory as home directory
- DefaultRoot /home/FTP-shared
- # Lock all the users in home directory, ***** really important *****
- DefaultRoot ~
- MaxLoginAttempts 5
- #VALID LOGINS
- AllowUser userftp
- DenyALL
- Umask 022 022
- AllowOverwrite off
- DenyAll
- Umask 022 022
- AllowOverwrite off
- DenyAll
- Umask 022 022
- AllowOverwrite on
- DenyAll
- AllowAll
好了,你已經(jīng)完成了proftpd的配置,你的服務(wù)端口是1980,而讀取的參數(shù)如下,用戶:sauron,密碼:你為userftp設(shè)置的那個。
4- 啟動/停止/重啟動你的服務(wù):
- Code:
- sudo /etc/init.d/proftpd start
- sudo /etc/init.d/proftpd stop
- sudo /etc/init.d/proftpd restart
對你的proftpd進行一下語法檢查:
- Code:
- sudo proftpd -td5
想知道誰現(xiàn)在連接到你的服務(wù),用ftptop命令(使用字母"t"來轉(zhuǎn)換顯示頻率),你也可以使用"ftpwho"命令。
【編輯推薦】