VsFTPd的配置
VsFTPd的配置:vsFTPd的運行有兩種模式,一種是standalone "initd"模式,另外一種是xinetd模式。
兩種模式運行機(jī)制不是相同的,stardard initd模式,適合專業(yè)FTP,且FTP總是一直有人訪問,占用資源也是比較大,如果您的FTP總是有人訪問和登入。就要用這種模式。如果您的FTP訪問人數(shù)比較小,建議您用xinetd模式。xinetd模式,是當(dāng)用戶請求時,vsFTPd才會啟動。
不同的環(huán)境,當(dāng)然得用不同的啟動模式。
1] 我們主要把vsFTPd的配置文件改一下就行了。配制文件在/etc/vsftpd/vsftpd.conf,用您喜歡的編輯器打開。請參考下面的配置文件。
- # Example config file /etc/vsftpd.conf
- #
- # The default compiled in settings are very paranoid. This sample file
- # loosens things up a bit, to make the ftp daemon more usable.
- #
- # Allow anonymous FTP?
- anonymous_enable=YES
- #
- # Uncomment this to allow local users to log in.
- local_enable=YES
- #
- # Uncomment this to enable any form of FTP write command.
- write_enable=YES
- #
- # Default umask for local users is 077. You may wish to change this to 022,
- # if your users expect that (022 is used by most other ftpd's)
- local_umask=022
- #
- # Uncomment this to allow the anonymous FTP user to upload files. This only
- # has an effect if the above global write enable is activated. Also, you will
- # obviously need to create a directory writable by the FTP user.
- #anon_upload_enable=YES
- #
- # Uncomment this if you want the anonymous FTP user to be able to create
- # new directories.
- #anon_mkdir_write_enable=YES
- #
- # Activate directory messages - messages given to remote users when they
- # go into a certain directory.
- dirmessage_enable=YES
- #
- # Activate logging of uploads/downloads.
- xferlog_enable=YES
- #
- # Make sure PORT transfer connections originate from port 20 (ftp-data).
- connect_from_port_20=YES
- #
- # If you want, you can arrange for uploaded anonymous files to be owned by
- # a different user. Note! Using "root" for uploaded files is not
- # recommended!
- #chown_uploads=YES
- #chown_username=whoever
- #
- # You may override where the log file goes if you like. The default is shown
- # below.
- #xferlog_file=/var/log/vsftpd.log
- #
- # If you want, you can have your log file in standard ftpd xferlog format
- xferlog_std_format=YES
- #
- # You may change the default value for timing out an idle session.
- #idle_session_timeout=600
- #
- # You may change the default value for timing out a data connection.
- #data_connection_timeout=120
- #
- # It is recommended that you define on your system a unique user which the
- # ftp server can use as a totally isolated and unprivileged user.
- #nopriv_user=ftpsecure
- #
- # Enable this and the server will recognise asynchronous ABOR requests. Not
- # recommended for security (the code is non-trivial). Not enabling it,
- # however, may confuse older FTP clients.
- #async_abor_enable=YES
- #
- # By default the server will pretend to allow ASCII mode but in fact ignore
- # the request. Turn on the below options to have the server actually do ASCII
- # mangling on files when in ASCII mode.
- # Beware that turning on ascii_download_enable enables malicious remote parties
- # to consume your I/O resources, by issuing the command "SIZE /big/file" in
- # ASCII mode.
- # These ASCII options are split into upload and download because you may wish
- # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
- # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
- # on the client anyway..
- #ascii_upload_enable=YES
- #ascii_download_enable=YES
- #
- # You may fully customise the login banner string:
- #ftpd_banner=Welcome to blah FTP service.
- #
- # You may specify a file of disallowed anonymous e-mail addresses. Apparently
- # useful for combatting certain DoS attacks.
- #deny_email_enable=YES
- # (default follows)
- #banned_email_file=/etc/vsftpd.banned_emails
- #
- # You may specify an explicit list of local users to chroot() to their home
- # directory. If chroot_local_user is YES, then this list becomes a list of
- # users to NOT chroot().
- #chroot_list_enable=YES
- # (default follows)
- #chroot_list_file=/etc/vsftpd.chroot_list
- #
- # You may activate the "-R" option to the builtin ls. This is disabled by
- # default to avoid remote users being able to cause excessive I/O on large
- # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
- # the presence of the "-R" option, so there is a strong case for enabling it.
- #ls_recurse_enable=YES
- pam_service_name=vsftpd
- userlist_enable=YES
- #enable for standalone mode
- listen=YES
- tcp_wrappers=YES
#p#
2]更改完配置文件后,我們可以用下面的命令來重啟vsFTPd服務(wù)器
- [root@linuxsir001 root]# /etc/init.d/vsftpd restart
關(guān)閉 vsftpd: [ 確定 ]
為 vsftpd 啟動 vsftpd: [ 確定 ]
- [root@linuxsir001 root]#
3]以匿名方式來訪問測試,在text模式下:
注意:在text模式下,要用用戶名ftp,密碼ftp來訪問,這才是在text中匿名訪問FTP??慈缦碌牟僮鳎?/P>
- [root@linuxsir001 root]# ftp 192.168.0.1
- Connected to 192.168.0.1.
- 220 (vsFTPd 1.1.3)
- 530 Please login with USER and PASS.
- 530 Please login with USER and PASS.
- KERBEROS_V4 rejected as an authentication type
- Name (192.168.0.1:root): ftp 這里寫上ftp
- 331 Please specify the password.
- Password:[這里添寫ftp的密碼],匿名登入密碼也是ftp
- 230 Login successful. Have fun.
- Remote system type is UNIX.
- Using binary mode to transfer files.
- ftp> ls
- 227 Entering Passive Mode (192,168,0,1,137,151)
- 150 Here comes the directory listing.
- drwxr-xr-x 6 0 0 4096 May 25 13:54 RedHat90
- drwxr-xr-x 2 0 0 4096 Feb 28 19:21 pub
- 226 Directory send OK.
- ftp>
那匿名用戶所訪問的是哪個目錄?是/var/ftp這個目錄
出現(xiàn)問題的解決:有時出錯,是因為沒有ftp和nobody用戶,所以要在系統(tǒng)中添加這兩個用戶,一般的情況下,這兩個用戶在系統(tǒng)中是存在的??聪旅娴牟僮?。
- [root@linuxsir001 root]# adduser ftp
- adduser: user ftp exists
- [root@linuxsir001 root]# adduser nobody
- adduser: user nobody exists
從上面的操作中可知ftp和nobody用戶是存在的,所以沒有必要添加ftp和nobody用戶了。如果不存在,一定要添加這兩個用戶,否則會出現(xiàn)匿名用戶不能訪問的情況。
4]如果要以系統(tǒng)中存在的普通用戶登入FTP,也沒有什么可以設(shè)置的,添加一個用戶就行。比如我要添加beinan這個用戶,就要用下面的辦法
- [root@linuxsir001 root]# adduser beinan
- [root@linuxsir001 root]# passwd beinan
- Changing password for user beinan.
- New password:
- BAD PASSWORD: it does not contain enough DIFFERENT characters
- Retype new password:
- passwd: all authentication tokens updated successfully.
- [root@linuxsir001 root]#
這樣的話,就在/home目錄中出現(xiàn)一個beinan的用戶目錄:如下:
- [root@linuxsir001 root]# ls /home/
- beinan
如果我們想讓beinan這個用戶作為虛擬用戶,也就是說,beinan這個用戶是不能登入系統(tǒng)的,只能是登入FTP。 那這樣的用戶應(yīng)該如何添加呢??
- [root@linuxsir001 backupNow]# adduser -g ftp -s /sbin/nologin beinan
- [root@linuxsir001 backupNow]# passwd beinan
- Changing password for user beinan.
- New password:
- Retype new password:
- passwd: all authentication tokens updated successfully.
- [root@linuxsir001 backupNow]#
注:這僅僅是vsFTPd添加虛擬用戶的一個方法,還有更好的辦法需要我們?nèi)W(xué)習(xí)!另外的辦法也在測試之中。嚴(yán)格上來說,這種辦法不能算虛擬用戶。還有另外的一個辦法,就是通過pam認(rèn)證,用db_load來添加用戶,目前我也弄成功了,不過相對要復(fù)雜一點。正在測試之中。
如果我們想把用戶目錄定位到別的目錄應(yīng)該怎么辦呢??這個也比較簡單,看一下useradd就比較明白了。比如我想添加beinan這個用戶,并把目錄放在/opt目錄中:如下操作:
- [root@linuxsir001 root]# adduser -d /opt/beinan beinan
- [root@linuxsir001 root]# passwd beinan
- Changing password for user beinan.
- New password:
- Retype new password:
- passwd: all authentication tokens updated successfully.
如果是添加虛擬用戶,也就是不讓用戶登入系統(tǒng),只能登入FTP的用戶。如果我們想把beinan這個用戶目錄定位在/opt/beinan這個目錄中,根據(jù)上面的方法。我們應(yīng)該如下操作
- [root@linuxsir001 backupNow]# adduser -d /opt/beinan -g ftp -s /sbin/nologin beinan
- [root@linuxsir001 backupNow]# passwd beinan
- Changing password for user beinan.
- New password:
- Retype new password:
- passwd: all authentication tokens updated successfully.
- [root@linuxsir001 backupNow]#
看一下是不是已經(jīng)成功添加到了beinan這個用戶,并把beinan的家目錄放在了/opt目錄中呢??
- [root@linuxsir001 root]# ls /opt/
- beinan
證明已經(jīng)成功。
#p#
我們可以在text模式下以beinan用戶登入,然后來訪問ftp。
- [root@linuxsir001 root]# ftp 192.168.0.1
- Connected to 192.168.0.1.
- 220 (vsFTPd 1.1.3)
- 530 Please login with USER and PASS.
- 530 Please login with USER and PASS.
- KERBEROS_V4 rejected as an authentication type
- Name (192.168.0.1:root): beinan
- 331 Please specify the password.
- Password:
- 230 Login successful. Have fun.
- Remote system type is UNIX.
- Using binary mode to transfer files.
- ftp>
是不是成功了呢?
我們也可以用gftp來訪問beinan用戶,并上傳相應(yīng)的東西,所傳上的東西就放在beinan用戶所在的家目錄中,普通用戶的家目錄在哪里,寫您所用的添加用戶的方法有關(guān)。我在前面已經(jīng)說了兩種辦法,一種是默認(rèn)的添加方法,就是放在/home目錄中。
在本例中,我是采用默認(rèn)的添加用戶的方法。也就是不特別指定用戶用戶,這樣的話,用戶目錄就在/home目錄中。比如用beinan登入FTP時,訪問的就是/home/beinan這個目錄。讓傳的東西也在這個目錄中。匿名用戶所訪問是:/var/ftp這個目錄。
【編輯推薦】