IT貓撲網(wǎng):您身邊最放心的安全下載站! 最新更新|軟件分類|軟件專題|手機(jī)版|論壇轉(zhuǎn)貼|軟件發(fā)布

您當(dāng)前所在位置:首頁(yè)服務(wù)器FTP服務(wù)器 → linux下ftp服務(wù)器的搭建

linux下ftp服務(wù)器的搭建

時(shí)間:2015/6/28來(lái)源:IT貓撲網(wǎng)作者:網(wǎng)管聯(lián)盟我要評(píng)論(0)

  RHEL4中ftp服務(wù)器的搭建

  首先修改配置文件使主機(jī)獲得永久ip地址

  # vi /etc/sysconfig/network-scripts/ifcfg-eth0

  DEVICE=eth0

  BOOTPROTO=static

  IPADDR=172.16.16.111

  NETMASK=255.255.0.0

  GATEWAY=172.16.16.1

  ONBOOT=yes

  TYPE=Ethernet

  重啟配置文件使之生效

  # /etc/init.d/network restart

  Shutting down interface eth0:  [  OK  ]

  Shutting down loopback interface:  [  OK  ]

  Setting network parameters:  [  OK  ]

  Bringing up loopback interface:  [  OK  ]

  Bringing up interface eth0:  [  OK  ]

  需要關(guān)掉iptables系統(tǒng)防火墻,使用命令:

  # service iptables stop

  把安全級(jí)別調(diào)低

  # vi /etc/selinux/config

  把其中的:SELINUXTYPE=targeted改為SELINUXTYPE=disabled

  在系統(tǒng)中vsftpd并沒(méi)被默認(rèn)安裝,需要使用rpm命令安裝一下

  它在RHEL4的第1張光盤(pán)中,包文件的名稱是vsftpd-2.0.1-5.i386.rpm

  首先需要掛載光盤(pán)

  # mount /dev/cdrom /media/cdrom

  # cd /media/cdrom/RedHat/RPMS

  # ls -l vsftpd*

  -rw-r--r--  25 root root 122195 Jan  6  2005 vsftpd-2.0.1-5.i386.rpm

  掛載上去后,把它安裝上去

  # rpm -ivh vsftpd-2.0.1-5.i386.rpm

  warning: vsftpd-2.0.1-5.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e

  Preparing...    ########################################### [100%]

  我們看一下vsftpd.conf的配置文件

  # grep -v '#' /etc/vsftpd/vsftpd.conf(去除注釋行后的配置文件)

  anonymous_enable=YES     //anonymous_enable設(shè)置為yes時(shí),ftp服務(wù)器允許匿名登錄,即用戶可使用用戶名ftp或anonymous進(jìn)行ftp登錄,登錄口令為用戶E-mail地址。

  local_enable=YES     //local_enable設(shè)置為yes時(shí)允許本地用戶登錄,本地用戶指lunux系統(tǒng)中的用戶賬號(hào)。

  write_enable=YES     //write_enable設(shè)置為yes時(shí),ftp服務(wù)器開(kāi)放對(duì)本地用戶的寫(xiě)權(quán)限

  local_umask=022     //local_umask設(shè)置項(xiàng)設(shè)置本地用戶的文件生成掩碼,配置文件中的設(shè)置為022。

  dirmessage_enable=YES    //dirmessage_enable設(shè)置為yes時(shí),當(dāng)切換到ftp服務(wù)器中的某個(gè)目錄時(shí),將顯示該目錄下的".message"隱含文件的內(nèi)容.

  xferlog_enable=YES     //xferlog_enable設(shè)置為yes時(shí),ftp服務(wù)器將啟用上傳和下載日志。

  connect_from_port_20=YES     //connect_from_port_20設(shè)置為yes時(shí),ftp服務(wù)器將啟用ftp數(shù)據(jù)端口的連接請(qǐng)求。

  xferlog_std_format=YES     //xferlog_std_format設(shè)置為yes時(shí),ftp服務(wù)器將使用標(biāo)準(zhǔn)的ftpd xferlog日志格式。

  pam_service_name=vsftpd      //pam_service_name設(shè)置PAM認(rèn)證服務(wù)的配置文件名稱,該文件保存在"/etc/pam.d/"目錄下。

  userlist_enable=YES     //userlist_enable設(shè)置為yes時(shí),ftp服務(wù)器將檢查userlist_file設(shè)置文件中指定的用戶是否可以訪問(wèn)vsftpd服務(wù)器;userlist_file配置項(xiàng)的默認(rèn)值是"/etc/vsftpd.usr_list"文件。

  listen=YES     //listen設(shè)置為yes時(shí),ftp服務(wù)器將處于獨(dú)立啟動(dòng)模式。

  tcp_wrappers=YES     //tcp_wrappers設(shè)置為yes時(shí),ftp服務(wù)器將使用tcp_wrappes作為主機(jī)訪問(wèn)控制方式。tcp_wrappers可以實(shí)現(xiàn)linux系統(tǒng)中網(wǎng)絡(luò)服務(wù)的基于主機(jī)地址的訪問(wèn)控制,在"/etc"目錄中的hosts.allow和host.deny兩個(gè)文件用于設(shè)置tcp_wrappers的訪問(wèn)控制,hosts.allow文件設(shè)置允許訪問(wèn)記錄,host.deny文件設(shè)置拒絕訪問(wèn)記錄。

  啟動(dòng)vsftpd服務(wù)器

  # service vsftpd start

  Starting vsftpd for vsftpd: [  OK  ]

  關(guān)閉可以使用:

  service vsftpd stop

  Shutting down vsftpd: [  OK  ]

  查看服務(wù)器的運(yùn)行狀態(tài)使用:

  # service vsftpd status

  vsftpd is stopped

  添加兩個(gè)本地用戶,使用本地用戶登錄ftp

  # useradd aa

  # passwd aa

  # useradd bb

  # passwd bb

  并改變目錄的屬主和屬組

  # chown aa.aa /home/aa

  # chown bb.bb /home/bb

  # ls -l /home

  total 24

  drwx------  4 aa   aa   4096 May 26 12:15 aa

  drwx------  4 bb   bb   4096 May 26 12:16 bb

  設(shè)置宿主目錄權(quán)限

  # chmod 770 /home/aa

  # chmod 770 /home/bb

  # ls -l /home

  total 24

  drwxrwx---  4 aa   aa   4096 May 26 12:15 aa

  drwxrwx---  4 bb   bb   4096 May 26 12:16 bb

  這時(shí)可以登錄ftp

  1、使用匿名用戶登錄

  # ftp 172.16.16.121

  Connected to 172.16.16.121.

  220 (vsFTPd 2.0.1)

  530 Please login with USER and PASS.

  530 Please login with USER and PASS.

  KERBEROS_V4 rejected as an authentication type

  Name (172.16.16.121:root): anonymous

  331 Please specify the password.

  Password:

  230 Login successful.

  Remote system type is UNIX.

  Using binary mode to transfer files.

  ftp> ls

  227 Entering Passive Mode (172,16,16,121,208,47)

  150 Here comes the directory listing.

  drwxr-xr-x    2 0  0      4096 Oct 04  2004 pub

  226 Directory send OK.

  其中匿名用戶登錄使用ftp或anonymous作為ftp登錄的用戶名,在vsftpd的默認(rèn)設(shè)置時(shí)輸入任何字符串或直接回車(chē)都可以登錄,匿名用戶登錄后將以ftp服務(wù)器系統(tǒng)中的"/var/ftp"目錄作為匿名用戶的ftp根目錄。

#p#副標(biāo)題#e#

  2、使用本地用戶登錄

  # ftp 172.16.16.121

  Connected to 172.16.16.121.

  220 (vsFTPd 2.0.1)

  530 Please login with USER and PASS.

  530 Please login with USER and PASS.

  KERBEROS_V4 rejected as an authentication type

  Name (172.16.16.121:root): aa

  331 Please specify the password.

  Password:

  230 Login successful.

  Remote system type is UNIX.

  Using binary mode to transfer files.

  ftp> ls

  227 Entering Passive Mode (172,16,16,121,223,86)

  150 Here comes the directory listing.

  -rw-r--r--    1 0  0  19 May 26 03:48 11.txt

  226 Directory send OK.

  使用put命令可以將ftp客戶機(jī)中的文件上傳到ftp服務(wù)器中。

  ftp> put 22.txt

  local: 22.txt remote: 22.txt

  227 Entering Passive Mode (172,16,16,121,86,19)

  150 Ok to send data.

  226 File receive OK.

  30 bytes sent in 0.00086 seconds (34 Kbytes/s)

  使用get命令可以將ftp服務(wù)器中的文件下載到ftp客戶機(jī)中。

  ftp> get 22.txt

  local: 22.txt remote: 22.txt

  227 Entering Passive Mode (172,16,16,121,143,82)

  150 Opening BINARY mode data connection for 22.txt (30 bytes).

  226 File send OK.

  30 bytes received in 0.0005 seconds (58 Kbytes/s)

  不過(guò)使用本地ftp用戶賬號(hào)存在一定的安全性,首先它是系統(tǒng)賬號(hào),一旦ftp服務(wù)器出現(xiàn)安全漏洞會(huì)對(duì)整個(gè)ftp服務(wù)器所在的linux主機(jī)造成威脅;另外就是本地用戶賬號(hào)可以離開(kāi)用戶宿主目錄,轉(zhuǎn)換到系統(tǒng)中的其他目錄中,這對(duì)系統(tǒng)的安全有著一定的威脅。

  可是設(shè)置ftp本地用戶禁錮在宿主目錄中,這樣可以防止它切換到其他的目錄中。

  在vsftpd服務(wù)器的配置文件vsftpd.conf中添加配置項(xiàng)chroot_local_user設(shè)置為YES,vsftpd服務(wù)器將會(huì)把本地用戶禁錮在用

關(guān)鍵詞標(biāo)簽:linux,ftp服務(wù)器

相關(guān)閱讀

文章評(píng)論
發(fā)表評(píng)論

熱門(mén)文章 Linux文件傳送命令SCP(Secure Copy)Linux文件傳送命令SCP(Secure Copy)圖解Windows xp—FTP服務(wù)器配置圖解Windows xp—FTP服務(wù)器配置在Windows 2003下搭建FTP服務(wù)器在Windows 2003下搭建FTP服務(wù)器使用CesarFTP架設(shè)FTP服務(wù)器使用CesarFTP架設(shè)FTP服務(wù)器

相關(guān)下載

人氣排行 vsftp配置大全---超完整版IIS6.0打造FTP服務(wù)器完全圖文詳解使用Win 2003搭建安全文件服務(wù)器圖解Windows xp—FTP服務(wù)器配置在Windows 2003下搭建FTP服務(wù)器linux服務(wù)samba的詳細(xì)配置Windows內(nèi)置FTP服務(wù)器高級(jí)配置Windows XP系統(tǒng)下架設(shè)FTP服務(wù)器的步驟