約定:
1。本帖操作環境是Redhat 9.0,VSFTPD的版本是Redhat 9.0所帶的vsftpd-1.1.3-8.i386.rpm,在安裝盤的第三張中
2。VSFTPD實現的最基本的目的:用系統中存在的真實用戶能登入FTP,能用匿名訪問。
3。服務器的IP和和DNS設定
第一塊網卡
IP:192.168.0.1
子掩碼:255.255.255.0
網關不設置:
第二塊網卡:
IP:192.168.0.2
子掩碼:255.255.255.0
網關不設置
因為我的操作環境是一個小型的局域網,所以其它的機器的IP都是在192.168.0這個網段上。ADSL是接在服務器的第一個網卡上。服務器的第二個網卡是接集線器,其它的客戶機都是接在集線器上。為了能讓ADSL訪問internet,因為自己手動設置了IP,所以DNS也要自己來設置,DNS如下:
202.96.134.133
202.96.168.68
設置工具是:
[root@linuxsir001 root]# redhat-config-network
一。用VSFTP來架設FTP服務器,VSFTP服務器是目前最好的FTP服務器軟件,優點是體積小,可定制強,效率高
1。查看是否安裝了vsftpd軟件
[root@linuxsir001 root]# rpm -qa | grep vsftpd
如果沒有任何顯示,說明沒有把vsftpd安裝上,如果出現的是下面的這樣的提示,就證明已經安裝上了。
[root@linuxsir001 root]# rpm -qa | grep vsftpd
vsftpd-1.1.3-8
我以Redhat 9.0,以其自帶的vsftpd包vsftpd-1.1.3-8版本來為本帖約定。
[root@linuxsir001 root]# rpm -ivh vsftpd*.rpm
2。打開VSFTP服務器。
[root@linuxsir001 root]# ntsysv
把vsftpd服務器打開,也就是在運行 ntsysv命令后,把vsftpd服務選中。
[*] vsftpd
3。運行/etc/init.d/vsftpd start
[root@linuxsir001 root]# /etc/init.d/vsftpd start
為 vsftpd 啟動 vsftpd: [ 確定 ]
[root@linuxsir001 root]#
4。配制VSFTP,FVSFTP的運行有兩種模式,一種是stardard "initd模式,另外一種是xinetd模式,上面我們所說的就是stardard initd運行模式。兩種模式運行機制不是相同的,stardard initd模式,適合專業FTP,且FTP總是一直有人訪問,占用資源也是比較大,如果您的FTP總是有人訪問和登入。就要用這種模式。如果您的FTP訪問人數比較小,建議您用xinetd模式。xinetd模式,是當用戶請求時,vsftpd才會啟動。
不同的環境,當然得用不同的啟動模式。
如果想了解更多的,請在本帖后面跟帖,我會慢慢補充xinetd模式,以及虛擬用戶如何設置方面的問題。
1]我們主要把vsftp的配制文件改一下就行了。配制文件在/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
2]更改完配制文件后,我們可以用下面的命令來重啟VSFTPD服務器
[root@linuxsir001 root]# /etc/init.d/vsftpd restart
關閉 vsftpd: [ 確定 ]
為 vsftpd 啟動 vsftpd: [ 確定 ]
[root@linuxsir001 root]#
3]以匿名方式來訪問測試,在text模式下:
注意:在text模式下,要用用戶名ftp,密碼ftp來訪問,這才是在text中匿名訪問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): ftp 這里寫上ftp
331 Please specify the password.
Password:[這里添寫ftp的密碼],匿名登入密碼也是ftp
230 Login suclearcase/" target="_blank" >ccessful. 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這個目錄
出現問題的解決:有時出錯,是因為沒有ftp和nobody用戶,所以要在系統中添加這兩個用戶,一般的情況下,這兩個用戶在系統中是存在的??聪旅娴牟僮?。
[root@linuxsir001 root]# adduser ftp
adduser: user ftp exists
[root@linuxsir001 root]# adduser nobody
adduser: user nobody exists
從上面的操作中可知ftp和nobody用戶是存在的,所以沒有必要添加ftp和nobody用戶了。如果不存在,一定要添加這兩個用戶,否則會出現匿名用戶不能訪問的情況。
4]如果要以系統中存在的普通用戶登入FTP,也沒有什么可以設置的,添加一個用戶就行。比如我要添加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目錄中出現一個beinan的用戶目錄:如下:
[root@linuxsir001 root]# ls /home/
beinan
如果我們想讓beinan這個用戶作為虛擬用戶,也就是說,beinan這個用戶是不能登入系統的,只能是登入FTP。 那這樣的用戶應該如何添加呢??
[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]#
注:這僅僅是VSFTP添加虛擬用戶的一個方法,還有更好的辦法需要我們去學習!另外的辦法也在測試之中。嚴格上來說,這種辦法不能算虛擬用戶。還有另外的一個辦法,就是通過pam認證,用db_load來添加用戶,目前我也弄成功了,不過相對要復雜一點。正在測試之中。
如果我們想把用戶目錄定位到別的目錄應該怎么辦呢??這個也比較簡單,看一下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.
如果是添加虛擬用戶,也就是不讓用戶登入系統,只能登入FTP的用戶。如果我們想把beinan這個用戶目錄定位在/opt/beinan這個目錄中,根據上面的方法。我們應該如下操作
[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]#
看一下是不是已經成功添加到了beinan這個用戶,并把beinan的家目錄放在了/opt目錄中呢??
[root@linuxsir001 root]# ls /opt/
beinan
證明已經成功。
我們可以在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用戶,并上傳相應的東西,所傳上的東西就放在beinan用戶所在的家目錄中,普通用戶的家目錄在哪里,寫您所用的添加用戶的方法有關。我在前面已經說了兩種辦法,一種是默認的添加方法,就是放在/home目錄中。
在本例中,我是采用默認的添加用戶的方法。也就是不特別指定用戶用戶,這樣的話,用戶目錄就在/home目錄中。比如用beinan登入FTP時,訪問的就是/home/beinan這個目錄。讓傳的東西也在這個目錄中。
那匿名用戶所訪問的是哪個目錄呢???
應該是:/var/ftp這個目錄
5]訪問ftp的幾種方法
第一種方法就是text訪問,也就是用ftp命令來訪問。這個前面已經說過了。
第二種方法是以客戶端FTP軟件來訪問,在linux中有gftp。在本例中,我的FTP地址是通過局域網訪問的。地址欄中,添上192.168.0.1,端口是21,用戶名和密碼的添寫,如果您是用匿名登入,請不要添寫用戶名和密碼。如果用普通用戶登入,這個是必須要用用戶名和密碼的。
第三種辦法是和瀏覽器訪問:如果匿名登入,就直接用下面的方法:
ftp://192.168.0.1
如果是用戶登入方式,應該是
ftp://beinan@192.168.0.1
如果想讓在互聯網上的用戶能訪問到,如果您是用ADSL來訪問互聯網,要查找到您的動態IP,用下面的辦法
[root@linuxsir001 root]# ifconfig ppp0
ppp0 Link encap:Point-to-Point Protocol
inet addr:218.61.7.23 P-t-P:218.61.7.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:24245 errors:0 dropped:0 overruns:0 frame:0
TX packets:20411 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:23103297 (22.0 Mb) TX bytes:3588337 (3.4 Mb)
從上面的可以知道,能讓在internet訪問的地址是:218.61.7.23
二。如何讓局域網通過這個FTP安裝Linux呢??以Redhat 9.0為例:
1。我們要在/var/ftp中,為每個發行版建一個目錄,然后把每個發行版的每個版本再建一個目錄。把每個版本的ISO都解壓到相應的目錄里。舉個例子:
比如我想讓其它的客戶機,通過我的服務器來安裝Redhat9.0,我就要在/var/ftp目錄中建一個RedHat90的目錄,然后把RedHat 9.0的三個ISO都解到這個目錄中。
這樣服務器的設置就完成了。
2??蛻魴C方面如何引導及設置???我們可以做一個系統的引志盤,但有的發行版也沒有必要。這也要以各個發行版的情況而定。比如Redhat 9.0的安裝,如果您的客戶機上有windows,就直接通過局域網的FTP,dosutils images isolinux三個目錄放到一個在fat32分區中建的目錄中,比如說在客戶機上建一個Redhat9的目錄,然后把三個文件拷到客戶機中的fat32分區中的Redhat9的目錄中。
3.客戶機安裝及操作:
以DOS盤引導,不要加載CDROM,直接進入客戶機中fat32分區Redhat9\dosutils目錄,執行下面的命令。
autoboot
這樣就開始了安裝:
4.出現的畫面中,我們要選ftp安裝。在設置網絡環境時,我們要設置好IP和網關之類的。
以我的局域網為例:
客戶機的IP設置成192.168.0.5,掩碼也是2552555.255.0,網關設置成192.168.0.1。name 服務可以不設置。以匿名方式訪問FTP。
下一步會出現讓我們添寫FTP,及安裝源的地址,還是以我的局域網為例:
地址:192.168.0.1
路徑:因為我是把三個ISO放在了/var/ftp/RedHat90的目錄下,我應該寫如下的
/RedHat90
這樣就OK了,一切和其它的安裝方式都是一樣的了。
因為每個發行版不太一樣,所以通過網絡安裝,有的要做引導盤,如何做引導盤,我想大家早就知道了。如果不知道這方面的,請用搜索來找這方面的帖子。
安裝配置一個proftpd的實例
http://www.chinaunix.net 作者:wd 發表于:2004-06-11 16:22:19
安裝配置一個proftpd的實例
目的:
安裝配置一個proftpd,達到以下要求
1 不允許匿名訪問。
2 開放一個帳號,只有在upload目錄有上傳權限,可以續傳,不能改名和刪除。
操作:
0 切換到root帳戶
[code:1:0258b10472] su root //輸入root的密碼。
[/code:1:0258b10472]
1 下載proftpd
地址:www.proftpd.org。這里我們下載了1.2.9版本
[code:1:0258b10472] wget ftp://ftp.proftpd.org/distrib/source/proftpd-1.2.9.tar.gz
[/code:1:0258b10472]
2 安裝proftpd
切換到下載目錄,假設為/tmp/proftpd,然后
[code:1:0258b10472] tar zxvf proftpd-1.2.9.tar.gz //解壓
cd proftpd-1.2.9
./configure --prefix=/var/proftpd --sysconfdir=/etc //設置安裝目錄/var/proftpd,配置文件目錄/etc
make
make install
[/code:1:0258b10472]
3 新建ftp專用帳號
就是上面目的中提到的那個專用帳號,這里以skate/skate(u/p)為例。
[code:1:0258b10472] groupadd skate
useradd skate -g skate -d /var/ftp -s /sbin/nologin //設置/var/ftp目錄為ftp的目錄
passwd skate //設置skate用戶的密碼
mkdir /var/ftp/upload
chown skate.skate /var/ftp/upload //設置upload目錄skate用戶可寫
[/code:1:0258b10472]
4 設置proftpd
proftpd的配置文件就一個,就是/etc/proftpd.conf
[code:1:0258b10472] vi /etc/proftpd.conf //打開proftpd.conf
[/code:1:0258b10472]
[code:1:0258b10472]
####具體配置如下######
ServerName "Test ftp server..."
ServerType standalone
DefaultServer on
#端口
Port 21
Umask 022
#最大線程數
MaxInstances 30
User skate
Group skate
#DNS反查
UseReverseDNS off
IdentLookups off
#最大嘗試連接次數
MaxLoginAttempts 3
#每用戶線程
MaxClientsPerHost 2
#最大用戶數
MaxClients 20
DirFakeUser On skate
DirFakeGroup On skate
DeferWelcome On
#日志文件位置
SystemLog /var/log/proftpd.log
ServerIdent off
#限制skate組的skate用戶登錄時不能切換到其他目錄(只能呆在他的home目錄)
DefaultRoot ~ skate,skate
#設置只允許192.168.0的用戶登錄
# 原文轉自:http://www.anti-gravitydesign.com