Linux安裝FTP服務(wù)
ftp服務(wù)器
1、 在Linux和其他機(jī)器之間共享文件(在linux下安裝ftp)
2、 具體安裝步驟:
a) 首先查看我的Redhat5上是否已經(jīng)安裝
rpm -qa|grep vsftpd
b) 查看服務(wù)的運(yùn)行狀態(tài);
Service iptables status
c) 安裝. 如果沒有安裝話,就要選擇一種方式安裝
i. 可以到官方網(wǎng)站去下載
也可以用光盤安裝,RedHat 5的安盤里自帶的,所以我選擇光盤安裝
ii. (1)先把光盤 掛載到系統(tǒng)上:
mount /dev/cdrom /mnt
這樣光盤的內(nèi)容就被掛載到/mnt的設(shè)備上,現(xiàn)在可以通過/mnt訪問光盤上的內(nèi)容了
iii. .進(jìn)入光盤,查找安裝包,cd /mnt/Packages
iv. 4.找到安裝包vsftp-0.17-17.i386.rpm
v. 5.安裝程序,rpm -ivh vsftp-0.17-17.i386.rpm
vi. 再rpm -qa| grep vsftpd檢測是否安裝(出現(xiàn)rpm -ivh vsftp-0.17-17.i386.rpm表示已經(jīng)安裝完成)
3、 ftp服務(wù)的啟動和關(guān)閉命令為:service vsftpd strat/stop/restart
4、 默認(rèn)的ftp服務(wù)器命令:
a) 啟動:service vsftpd start(其中vsftpd的最后面的那個d代表是在后臺進(jìn)行的進(jìn)程)
b) 登錄:ftp localhost
c) 退出:bye
5、 Linux查詢ip(ifconfig)
6、 Vmware在安裝之后會有三個連接,兩個是虛擬的(也是windows用的),虛擬的那一塊網(wǎng)卡也是虛擬的,只要把這個網(wǎng)卡放在,其中的任何一個網(wǎng)段,就可以通了。
7、 在windows下ping linux如果linux下安裝了防火墻那么是ping不能的。在默認(rèn)情況下,linux是安裝防火墻的,防火墻也會阻止ftp服務(wù)器
解決辦法是,打開端口或者關(guān)閉防火墻
8、 關(guān)閉防火墻:service iptables stop
9、 當(dāng)不知道允許不允許,可以看ftp主要配置文件:
/etc/vsftpd下面vsftpd.conf
在linux下面大部分都有一個配置文件。
10、 VsFtp的配置文件
a) /etc/vsftpd/vsftpd.conf----------主配置文件
b) /etc/rc.d/init.d/vsftpd ----------啟動腳本
c) /etc/pam.d/vsftpd ----------- PAM認(rèn)證文件(此文件中file=/etc/vsftpd/ftpusers字段,指明阻止訪問的用戶來自/etc/vsftpd/ftpusers文件中的用戶)
d) /etc/vsftpd/ftpusers-------------禁止使用vsftpd的用戶列表文件。記錄不允許訪問FTP服務(wù)器的用戶名單,管理員可以把一些對系統(tǒng)安全有威脅的用戶賬號記錄在此文件中,以免用戶從FTP登錄后獲得大于上傳下載操作的權(quán)利,而對系統(tǒng)造成損壞。
e) /etc/vsftpd/user_list-------------禁止或允許使用vsftpd的用戶列表文件。這個文件中指定的用戶缺省情況(即在/etc/vsftpd/vsftpd.conf中設(shè)置userlist_deny=YES)下也不能訪問FTP服務(wù)器,在設(shè)置了userlist_deny=NO時,僅允許user_list中指定的用戶訪問FTP服務(wù)器。
f) /var/ftp -----------------------------匿名用戶主目錄;本地用戶主目錄為:/home/用戶主目錄,即登錄后進(jìn)入自己家目錄
g) /var/ftp/pub------------------------匿名用戶的下載目錄,此目錄需賦權(quán)根chmod 1777 pub(1為特殊權(quán)限,使上載后無法刪除)
h) /etc/logrotate.d/vsftpd.log--- Vsftpd的日志文件
11、下面對主要的配置文件進(jìn)行介紹:
#Example config file /etc/vsftpd/vsftpd.conf # Thedefault compiled in settings are fairly paranoid. This sample file #loosens things up a bit, to make the ftp daemon more usable. #Please see vsftpd.conf.5 forall compiled in defaults. # READTHIS: This example file is NOT an exhaustive list of vsftpd options. #Please read the vsftpd.conf.5 manualpage to get a full idea of vsftpd's #capabilities. #Allow anonymous FTP (Beware - allowed by default if you comment this out). anonymous_enable=YES ( 是否允許 匿名登錄FTP 服務(wù)器,默認(rèn)設(shè)置為YES 允許,即用戶可使用用戶名ftp 或anonymous 進(jìn)行ftp登錄,口令為用戶的E-mail 地址。如不允許匿名訪問去掉前面#并設(shè)置為NO ) #Uncomment this to allow local users to log in. local_enable=YES (是否允許本地用戶 ( 即 linux 系統(tǒng)中的用戶帳號) 登錄FTP服務(wù)器,默認(rèn)設(shè)置為YES允許, 本地用戶登錄后會進(jìn)入用戶主目錄,而匿名用戶登錄后進(jìn)入匿名用戶的下載目錄/var/ftp/pub ;若只允許匿名用戶訪問,前面加上#,可 阻止本地用戶訪問FTP 服務(wù)器。) #Uncomment this to enable any form of FTP write command. write_enable=YES ( 是否允許本地用戶對 FTP 服務(wù)器文件具有寫權(quán)限 , 默認(rèn)設(shè)置為 YES 允許 ) #Default umask for local users is 077. You may wish to change this to 022, # ifyour users expect that (022 is used by most other ftpd's) # local_umask=022 (或其它值,設(shè)置本地用戶的文件掩碼 為缺省022,也可根據(jù)個人喜好將其設(shè)置為其他值,默認(rèn)值為077) #Uncomment this to allow the anonymous FTP user to upload files. This only # hasan 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 ( 是否允許匿名用戶上傳文件 , 須將 write_enable=YES , 默認(rèn)設(shè)置為 YES 允許 ) #Uncomment this if you want the anonymous FTP user to be able to create # newdirectories. #anon_mkdir_write_enable=YES ( 是否允許匿名用戶創(chuàng)建新文件夾 , 默認(rèn)設(shè)置為 YES 允許 ) #Activate directory messages - messages given to remote users when they # gointo a certain directory. #dirmessage_enable=YES ( 是否激活目錄歡迎信息功能 , 當(dāng)用戶用 CMD模式首次訪問服務(wù)器上某個目錄時 ,F(xiàn)TP 服務(wù)器將顯示歡迎信息 , 默認(rèn)情況下 , 歡迎信息是通過 該 目錄下的 .message 文件獲得的,此文件保存自定義的歡迎信息,由用戶自己建立) #Activate logging of uploads/downloads. xferlog_enable=YES ( 默認(rèn)值為 NO 如果啟用此選項(xiàng),系統(tǒng)將會維護(hù)記錄服務(wù)器上傳和下載情況的日志文件,默認(rèn)情況該日志文件為/var/log/vsftpd.log, 也可以通過下面的 xferlog_file 選項(xiàng)對其進(jìn)行設(shè)定。) # Makesure PORT transfer connections originate from port 20 (ftp-data). connect_from_port_20=YES ( 設(shè)定 FTP 服務(wù)器將啟用 FTP 數(shù)據(jù)端口的連接請求 ,ftp-data 數(shù)據(jù)傳輸 ,21 為連接控制端口 ) # Ifyou want, you can arrange for uploaded anonymous files to be owned by # adifferent user. Note! Using "root" for uploaded files is not #recommended!-注意,不推薦使用 root 用戶上傳文件 #chown_uploads=YES ( 設(shè)定是否允許 改變 上傳文件的屬主 , 與下面一個設(shè)定項(xiàng)配合使用 ) #chown_username=whoeve r ( 設(shè)置想要改變的上傳文件的屬主 , 如果需要 , 則輸入一個系統(tǒng)用戶名 , 例如可以把上傳的文件都改成 root 屬主。whoever :任何人) # Youmay override where the log file goes if you like. The default is shown #below. #xferlog_file=/var/log/vsftpd.log ( 設(shè)定系統(tǒng)維護(hù)記錄FTP 服務(wù)器上傳和下載情況的日志文件,/var/log/vsftpd.log 是默認(rèn)的,也可以另設(shè)其它) # Ifyou want, you can have your log file in standard ftpd xferlog format #xferlog_std_format=YES ( 如果啟用此選項(xiàng) , 傳輸日志文件將以標(biāo)準(zhǔn) xferlog 的格式書寫,該格式的日志文件默認(rèn)為/var/log/xferlog,也可以通過xferlog_file 選項(xiàng)對其進(jìn)行設(shè)定,默認(rèn)值為NO) #dual_log_enable ( 如果添加并啟用此選項(xiàng),將生成兩個相似的日志文件,默認(rèn)在/var/log/xferlog和/var/log/vsftpd.log 目錄下。前者是wu_ftpd類型的傳輸日志,可以利用標(biāo)準(zhǔn)日志工具對其進(jìn)行分析;后者是vsftpd 類型的日志) #syslog_enable ( 如果添加并啟用此選項(xiàng),則原本應(yīng)該輸出到/var/log/vsftpd.log 中的日志,將輸出到系統(tǒng)日志中) # Youmay change the default value for timing out an idle session. #idle_session_timeout=600 (設(shè)置數(shù)據(jù)傳輸中斷間隔時間,此語句表示空閑的用戶會話中斷時間為600秒,即當(dāng)數(shù)據(jù)傳輸結(jié)束后,用戶連接FTP服務(wù)器的時間不應(yīng)超過600秒,可以根據(jù)實(shí)際情況對該值進(jìn)行修改) # Youmay change the default value for timing out a data connection. #data_connection_timeout=120 ( 設(shè)置數(shù)據(jù)連接超時時間 , 該語句表示數(shù)據(jù)連接超時時間為 120 秒 , 可根據(jù)實(shí)際情況對其個修改 ) # Itis recommended that you define on your system a unique user which the # ftpserver can use as a totally isolated and unprivileged user. #nopriv_user=ftpsecure ( 運(yùn)行 vsftpd 需要的非特權(quán)系統(tǒng)用戶,缺省是nobody ) #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 ( 如果 FTPclient 會下達(dá)“async ABOR ”這個指令時,這個設(shè)定才需要啟用,而一般此設(shè)定并不安全,所以通常將其取消) # Bydefault the server will pretend to allow ASCII mode but in fact ignore # therequest. Turn on the below options to have the server actually do ASCII #mangling on files when in ASCII mode. #Beware that on some FTP servers, ASCII support allows a denial of service #attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd #predicted this attack and has always been safe, reporting the size of the # rawfile. #ASCII mangling is a horrible feature of the protocol. #ascii_upload_enable=YES ( 大多數(shù) FTP 服務(wù)器都選擇用 ASCII 方式傳輸數(shù)據(jù) , 將 # 去掉就能實(shí)現(xiàn)用 ASCII 方式上傳和下載文件 ) #ascii_download_enable=YES ( 將 # 去掉就能實(shí)現(xiàn)用 ASCII 方式下載文件 ) # Youmay fully customise the login banner string: #ftpd_banner=Welcome to blah FTP service. (將#去掉可設(shè)置登錄FTP服務(wù)器時顯示的歡迎信息,可以修改=后的歡迎信息內(nèi)容。另外如在需要設(shè)置更改目錄歡迎信息的目錄下創(chuàng)建名為 .message 的文件,并寫入歡迎信息保存后,在進(jìn)入到此目錄會顯示自定義歡迎信息 ) # Youmay specify a file of disallowed anonymous e-mail addresses. Apparently #useful for combatting certain DoS attacks. #deny_email_enable=YES ( 可將某些特殊的 email address 抵擋住。如果以anonymous 登錄服務(wù)器時,會要求輸入密碼,也就是您的email address, 如果很討厭某些email address ,就可以使用此設(shè)定來取消他的登錄權(quán)限,但必須與下面的設(shè)置項(xiàng)配合 ) #(default follows) #banned_email_file=/etc/vsftpd/banned_emails (當(dāng)上面的 deny_email_enable=YES 時,可以利用這個設(shè)定項(xiàng)來規(guī)定那個email address 不可登錄vsftpd 服務(wù)器,此文件需用戶自己創(chuàng)建,一行一個email address 即可! ) # Youmay 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 ( 設(shè)置為 NO 時,用戶登錄FTP 服務(wù)器后具有訪問自己目錄以外的其他文件的權(quán)限, 設(shè)置為 YES 時 , 用戶被鎖定在自己的 home 目錄中,vsftpd 將在下面 chroot_list_file 選項(xiàng)值的位置尋找 chroot_list 文件,此文件需用戶建立, 再將需鎖定在自己home 目錄的用戶列入其中,每行一個用戶) #(default follows) #chroot_list_file=/etc/vsftpd/chroot_list ( 此文件需自己建立 , 被列入此文件的用戶 , 在登錄后將不能切換到自己目錄以外的其他目錄 , 由 FTP 服務(wù)器自動地 chrooted 到用戶自己的home 目錄下,使得 chroot_list 文件中的用戶不能隨意轉(zhuǎn)到其他用戶的FTP home 目錄下,從而有利于FTP 服務(wù)器的安全管理和隱私保護(hù)) # Youmay 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 # thepresence of the "-R" option, so there is a strong case for enablingit. #ls_recurse_enable=YES ( 是否允許遞歸查詢 , 大型站點(diǎn)的 FTP 服務(wù)器啟用此項(xiàng)可以方便遠(yuǎn)程用戶查詢 ) # When"listen" directive is enabled, vsftpd runs in standalone mode and #listens on IPv4 sockets. This directive cannot be used in conjunction # withthe listen_ipv6 directive. listen=YES ( 如果設(shè)置為 YES , 則 vsftpd 將以獨(dú)立模式運(yùn)行,由vsftpd 自己監(jiān)聽和處理連接請求) # Thisdirective enables listening on IPv6 sockets. To listen on IPv4 and IPv6 #sockets, you must run two copies of vsftpd whith two configuration files. # Makesure, that one of the listen options is commented !! #listen_ipv6=YES ( 設(shè)定是否支持IPV6) #pam_service_name=vsftpd ( 設(shè)置 PAM 外掛模塊提供的認(rèn)證服務(wù)所使用的配置文件名 ,即/etc/pam.d/vsftpd 文件,此文件中file=/etc/vsftpd/ftpusers字段,說明了PAM 模塊能抵擋的帳號內(nèi)容來自文件/etc/vsftpd/ftpusers中) #userlist_enable=YES/NO (此選項(xiàng)默認(rèn)值為NO , 此時ftpusers 文件中的用戶禁止登錄FTP 服務(wù)器;若此項(xiàng)設(shè)為YES ,則 user_list 文件中的用戶允許登錄 FTP 服務(wù)器,而如果同時設(shè)置了 userlist_deny=YES ,則 user_list 文件中的用戶將不允許登錄FTP 服務(wù)器,甚至連輸入密碼提示信息都沒有,直接被FTP 服務(wù)器拒絕) #userlist_deny=YES/NO (此項(xiàng)默認(rèn)為YES ,設(shè)置是否阻扯user_list 文件中的用戶登錄FTP 服務(wù)器) |
tcp_wrappers=YES ( 表明服務(wù)器使用 tcp_wrappers 作為主機(jī)訪問控制方式,tcp_wrappers 可以實(shí)現(xiàn)linux 系統(tǒng)中網(wǎng)絡(luò)服務(wù)的基于主機(jī)地址的訪問控制,在/etc 目錄中的hosts.allow 和hosts.deny 兩個文件用于設(shè)置tcp_wrappers 的訪問控制,前者設(shè)置允許訪問記錄,后者設(shè)置拒絕訪問記錄。例如想限制某些主機(jī)對FTP 服務(wù)器192.168.57.2 的匿名訪問,編緝/etc/hosts.allow 文件,如在下面增加兩行命令:vsftpd:192.168.57.1:DENY 和vsftpd:192.168.57.9:DENY 表明限制IP 為192.168.57.1/192.168.57.9 主機(jī)訪問IP 為192.168.57.2 的FTP服務(wù)器,此時FTP 服務(wù)器雖可以PING 通,但無法連接)
12、 匿名:anonymous,密碼是沒有的
13、 Vsftp根目錄 /var/ftp/
a) 向下面的pub里面下載文件就可以了
b) 如果要上傳,默認(rèn)不允許,匿名anonymous上傳。
14、很多ftp用戶管理跟linux用戶管理放在一起的
15、允許root用戶上傳(一般不用)
16、允許root上傳
a) 只需要更改兩個配置文件文件;(/etc/vsftpd)
b) 改配置文件vsftpd.user_list(把root用戶刪除或者用#注釋,#root)
c) 改配置文件vsftpd.user_ftpusers(把root用戶刪除或者用#注釋,#root)
d) 再重新啟動vsftp service vsftpd restart
在這種情況下用root登錄上去,默認(rèn)登錄根目錄
17、 默認(rèn)啟動設(shè)置:
a) 方法一:chkconfig vsftpdon或chkconfig –level 5 vsftpd on
b) 只要在第2--5為on就能隨機(jī)在哪個級別上啟動,
c) 查看啟動方式:chkconfig--list |grep vsftpd
d) 方法二:用vi打開:/etc/rc.local在里面加入/user/local/bin/vsftpd即可
18、在配置vsftpd過程中l(wèi)inux的selinux默認(rèn)下是啟動的,有時候這個東西有加強(qiáng)安全性的同時很討厭,比如讓配置好的vsftpd無法正常登錄,也無法上傳。此時可以采用兩種辦法。
i. 一種辦法:
#setsebool -P ftpd_disable_trans 1
然后重啟vsftpd服務(wù)。
ii. 另一種辦法,直接關(guān)掉selinux
vim /etc/sysconfig/selinux
selinux=disable
然后重啟即可。
19、 或者先查看selinux的狀態(tài): getsebool –a或sestatus -v
a) 使用setsebool命令開啟對應(yīng)屬性:setsebool ftpd_disable_trans on
b) setsebool使用-P參數(shù),無需每次開機(jī)都輸入這個命令: setsebool -Pftpd_disable_trans on
c) 獲取本機(jī)selinux策略值,也稱為bool值。:getsebool -a 命令或sestatus -b
posted on 2014-12-03 13:31 順其自然EVO 閱讀(1008) 評論(0) 編輯 收藏 所屬分類: linux