ftp伺服器
1、 在Linux和其他機器之間共用檔案(在linux下安裝ftp)
2、 具體安裝步驟:
a) 首先查看我的Redhat5上是否已經安裝
rpm -qa|grep vsftpd
b) 查看服務的運行狀態;
Service iptables status
c) 安裝. 如果沒有安裝話,就要選擇一種方式安裝
i. 可以到官方網站去下載
http://vsftpd.beasts.org
也可以用光碟片安裝,RedHat 5的安盤裡內建的,所以我選擇光碟片安裝
ii. (1)先把光碟片 掛載到系統上:
mount /dev/cdrom /mnt
這樣光碟片的內容就被掛載到/mnt的裝置上,現在可以通過/mnt訪問光碟片上的內容了
iii. .進入光碟片,尋找安裝包,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檢測是否安裝(出現rpm -ivh vsftp-0.17-17.i386.rpm表示已經安裝完成)
3、 ftp服務的啟動和關閉命令為:service vsftpd strat/stop/restart
4、 預設的ftp伺服器命令:
a) 啟動:service vsftpd start(其中vsftpd的最後面的那個d代表是在後台進行的進程)
b) 登入:ftp localhost
c) 退出:bye
5、 Linux查詢ip(ifconfig)
6、 Vmware在安裝之後會有三個串連,兩個是虛擬(也是windows用的),虛擬那一塊網卡也是虛擬,只要把這個網卡放在,其中的任何一個網段,就可以通了。
7、 在windows下ping linux如果linux下安裝了防火牆那麼是ping不能的。在預設情況下,linux是安裝防火牆的,防火牆也會阻止ftp伺服器
解決辦法是,開啟連接埠或者關閉防火牆
8、 關閉防火牆:service iptables stop
9、 當不知道允許不允許,可以看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認證檔案(此檔案中file=/etc/vsftpd/ftpusers欄位,指明阻止訪問的使用者來自/etc/vsftpd/ftpusers檔案中的使用者)
d) /etc/vsftpd/ftpusers-------------禁止使用vsftpd的使用者列表檔案。記錄不允許訪問FTP伺服器的使用者名稱單,管理員可以把一些對系統安全有威脅的使用者帳號記錄在此檔案中,以免使用者從FTP登入後獲得大於上傳下載操作的權利,而對系統造成損壞。
e) /etc/vsftpd/user_list-------------禁止或允許使用vsftpd的使用者列表檔案。這個檔案中指定的使用者預設情況(即在/etc/vsftpd/vsftpd.conf中設定userlist_deny=YES)下也不能訪問FTP伺服器,在設定了userlist_deny=NO時,僅允許user_list中指定的使用者訪問FTP伺服器。
f) /var/ftp -----------------------------匿名使用者主目錄;本機使用者主目錄為:/home/使用者主目錄,即登入後進入自己家目錄
g) /var/ftp/pub------------------------匿名使用者的下載目錄,此目錄需賦權根chmod 1777 pub(1為特殊許可權,使上傳後無法刪除)
h) /etc/logrotate.d/vsftpd.log--- Vsftpd的記錄檔
11、 下面對主要的設定檔進行介紹:
Ø #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 伺服器,預設設定為YES 允許,即使用者可使用使用者名稱ftp 或anonymous 進行ftp登入,口令為使用者的E-mail 地址。如不允許匿名訪問去掉前面#並設定為NO )
Ø #Uncomment this to allow local users to log in.
Ø local_enable=YES (是否允許本機使用者 ( 即 linux 系統中的使用者帳號) 登入FTP伺服器,預設設定為YES允許, 本機使用者登入後會進入使用者主目錄,而匿名使用者登入後進入匿名使用者的下載目錄/var/ftp/pub ;若只允許匿名使用者存取,前面加上#,可 阻止本機使用者訪問FTP 伺服器。)
Ø #Uncomment this to enable any form of FTP write command.
Ø write_enable=YES ( 是否允許本機使用者對 FTP 伺服器檔案具有寫入權限 , 預設設定為 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 (或其它值,設定本機使用者的檔案掩碼 為預設022,也可根據個人喜好將其設定為其他值,預設值為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 , 預設設定為 YES 允許 )
Ø #Uncomment this if you want the anonymous FTP user to be able to create
Ø # newdirectories.
Ø #anon_mkdir_write_enable=YES ( 是否允許匿名使用者建立新檔案夾 , 預設設定為 YES 允許 )
Ø #Activate directory messages - messages given to remote users when they
Ø # gointo a certain directory.
Ø #dirmessage_enable=YES ( 是否啟用目錄歡迎資訊功能 , 當使用者用 CMD模式首次訪問伺服器上某個目錄時 ,FTP 伺服器將顯示歡迎資訊 , 預設情況下 , 歡迎資訊是通過 該 目錄下的 .message 檔案獲得的,此檔案儲存自訂的歡迎資訊,由使用者自己建立)
Ø #Activate logging of uploads/downloads.
Ø xferlog_enable=YES ( 預設值為 NO 如果啟用此選項,系統將會維護記錄伺服器上傳和下載情況的記錄檔,預設情況該記錄檔為/var/log/vsftpd.log, 也可以通過下面的 xferlog_file 選項對其進行設定。)
Ø # Makesure PORT transfer connections originate from port 20 (ftp-data).
Ø connect_from_port_20=YES ( 設定 FTP 伺服器將啟用 FTP 資料連接埠的串連請求 ,ftp-data 資料轉送 ,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 ( 設定是否允許 改變 上傳檔案的屬主 , 與下面一個設定項配合使用 )
Ø #chown_username=whoeve r ( 設定想要改變的上傳檔案的屬主 , 如果需要 , 則輸入一個系統使用者名稱 , 例如可以把上傳的檔案都改成 root 屬主。whoever :任何人)
Ø # Youmay override where the log file goes if you like. The default is shown
Ø #below.
Ø #xferlog_file=/var/log/vsftpd.log ( 設定系統維護記錄FTP 伺服器上傳和下載情況的記錄檔,/var/log/vsftpd.log 是預設的,也可以另設其它)
Ø # Ifyou want, you can have your log file in standard ftpd xferlog format
Ø #xferlog_std_format=YES ( 如果啟用此選項 , 傳輸記錄檔將以標準 xferlog 的格式書寫,該格式的記錄檔預設為/var/log/xferlog,也可以通過xferlog_file 選項對其進行設定,預設值為NO)
Ø #dual_log_enable ( 如果添加並啟用此選項,將產生兩個相似的記錄檔,預設在/var/log/xferlog和/var/log/vsftpd.log 目錄下。前者是wu_ftpd類型的傳輸日誌,可以利用標準日誌工具對其進行分析;後者是vsftpd 類型的日誌)
Ø #syslog_enable ( 如果添加並啟用此選項,則原本應該輸出到/var/log/vsftpd.log 中的日誌,將輸出到系統日誌中)
Ø # Youmay change the default value for timing out an idle session.
Ø #idle_session_timeout=600 (設定資料轉送中斷間隔時間,此語句表示閒置使用者會話停機時間為600秒,即當資料轉送結束後,使用者串連FTP伺服器的時間不應超過600秒,可以根據實際情況對該值進行修改)
Ø # Youmay change the default value for timing out a data connection.
Ø #data_connection_timeout=120 ( 設定資料連線逾時時間 , 該語句表示資料連線逾時時間為 120 秒 , 可根據實際情況對其個修改 )
Ø # 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 ( 運行 vsftpd 需要的非特權系統使用者,預設是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 會下達“async ABOR ”這個指令時,這個設定才需要啟用,而一般此設定並不安全,所以通常將其取消)
Ø # 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 ( 大多數 FTP 伺服器都選擇用 ASCII 方式傳輸資料 , 將 # 去掉就能實現用 ASCII 方式上傳和下載檔案 )
Ø #ascii_download_enable=YES ( 將 # 去掉就能實現用 ASCII 方式下載檔案 )
Ø # Youmay fully customise the login banner string:
Ø #ftpd_banner=Welcome to blah FTP service. (將#去掉可設定登入FTP伺服器時顯示的歡迎資訊,可以修改=後的歡迎資訊內容。另外如在需要設定更改目錄歡迎資訊的目錄下建立名為 .message 的檔案,並寫入歡迎資訊儲存後,在進入到此目錄會顯示自訂歡迎資訊 )
Ø # Youmay specify a file of disallowed anonymous e-mail addresses. Apparently
Ø #useful for combatting certain DoS attacks.
Ø #deny_email_enable=YES ( 可將某些特殊的 email address 抵擋住。如果以anonymous 登入伺服器時,會要求輸入密碼,也就是您的email address, 如果很討厭某些email address ,就可以使用此設定來取消他的登入許可權,但必須與下面的設定項配合 )
Ø #(default follows)
Ø #banned_email_file=/etc/vsftpd/banned_emails (當上面的 deny_email_enable=YES 時,可以利用這個設定項來規定那個email address 不可登入vsftpd 伺服器,此檔案需使用者自己建立,一行一個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 ( 設定為 NO 時,使用者登入FTP 伺服器後具有訪問自己目錄以外的其他檔案的許可權, 設定為 YES 時 , 使用者被鎖定在自己的 home 目錄中,vsftpd 將在下面 chroot_list_file 選項值的位置尋找 chroot_list 檔案,此檔案需使用者建立, 再將需鎖定在自己home 目錄的使用者列入其中,每行一個使用者)
Ø #(default follows)
Ø #chroot_list_file=/etc/vsftpd/chroot_list ( 此檔案需自己建立 , 被列入此檔案的使用者 , 在登入後將不能切換到自己目錄以外的其他目錄 , 由 FTP 伺服器自動地 chrooted 到使用者自己的home 目錄下,使得 chroot_list 檔案中的使用者不能隨意轉到其他使用者的FTP home 目錄下,從而有利於FTP 伺服器的安全管理和隱私保護)
Ø # 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 ( 是否允許遞迴查詢 , 大型網站的 FTP 伺服器啟用此項可以方便遠端使用者查詢 )
Ø # 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 ( 如果設定為 YES , 則 vsftpd 將以獨立模式運行,由vsftpd 自己監聽和處理串連請求)
Ø # 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 ( 設定是否支援IPV6)
Ø #pam_service_name=vsftpd ( 設定 PAM 外掛模組提供的認證服務所使用的設定檔名 ,即/etc/pam.d/vsftpd 檔案,此檔案中file=/etc/vsftpd/ftpusers欄位,說明了PAM 模組能抵擋的帳號內容來自檔案/etc/vsftpd/ftpusers中)
Ø #userlist_enable=YES/NO (此選項預設值為NO , 此時ftpusers 檔案中的使用者禁止登入FTP 伺服器;若此項設為YES ,則 user_list 檔案中的使用者允許登入 FTP 伺服器,而如果同時設定了 userlist_deny=YES ,則 user_list 檔案中的使用者將不允許登入FTP 伺服器,甚至連輸入密碼提示資訊都沒有,直接被FTP 伺服器拒絕)
Ø #userlist_deny=YES/NO (此項預設為YES ,設定是否阻扯user_list 檔案中的使用者登入FTP 伺服器)
Ø tcp_wrappers=YES ( 表明伺服器使用 tcp_wrappers 作為主機存取控制方式,tcp_wrappers 可以實現linux 系統中網路服務的基於主機地址的存取控制,在/etc 目錄中的hosts.allow 和hosts.deny 兩個檔案用於設定tcp_wrappers 的存取控制,前者設定允許訪問記錄,後者設定拒絕訪問記錄。例如想限制某些主機對FTP 伺服器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 主機訪問IP 為192.168.57.2 的FTP伺服器,此時FTP 伺服器雖可以PING 通,但無法串連)
12、 匿名:anonymous,密碼是沒有的
13、 Vsftp根目錄 /var/ftp/
a) 向下面的pub裡面下載檔案就可以了
b) 如果要上傳,預設不允許,匿名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登入上去,預設登入根目錄
17、 預設啟動設定:
a) 方法一:chkconfig vsftpdon或chkconfig –level 5 vsftpd on
b) 只要在第2--5為on就能隨機在哪個層級上啟動,
c) 查看啟動方式:chkconfig--list |grep vsftpd
d) 方法二:用vi開啟:/etc/rc.local在裡面加入/user/local/bin/vsftpd即可
18、 在配置vsftpd過程中linux的selinux預設下是啟動的,有時候這個東西有加強安全性的同時很討厭,比如讓配置好的vsftpd無法正常登入,也無法上傳。此時可以採用兩種辦法。
i. 一種辦法:
#setsebool -P ftpd_disable_trans 1
然後重啟vsftpd服務。
ii. 另一種辦法,直接關掉selinux
vim /etc/sysconfig/selinux
selinux=disable
然後重啟即可。
19、 或者先查看selinux的狀態: getsebool –a或sestatus -v
a) 使用setsebool命令開啟對應屬性:setsebool ftpd_disable_trans on
b) setsebool使用-P參數,無需每次開機都輸入這個命令: setsebool -Pftpd_disable_trans on
c) 擷取本機selinux策略值,也稱為bool值。:getsebool -a 命令或sestatus -b