linux6中ftp安裝及使用者建立
阿新 • • 發佈:2019-02-20
一:安裝ftp
1.首先先安裝ftp,使用yum命令
[root@localhost /]# yum install vsftpd
2.修改/etc/vsftpd/vsftpd.conf
[root@localhost /]# vi /etc/vsftpd/vsftpd.conf
3.關閉匿名使用者登入
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
4.限制使用者只能訪問跟路徑(預設/home/test)
將chroot_list的兩個註釋解開,並且在/etc/vsftpd下建立chroot_root檔案,在檔案中新增你要限制的使用者,一個使用者一行,切記。# 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_local_user=YES chroot_list_enable=YES # (default follows) chroot_list_file=/etc/vsftpd/chroot_list
5.開啟監聽,曾在linux7中嘗試,卻始終無法啟動,後使用linux6.4一次就成功了,不知道為什麼。。。
其他不需要修改什麼了,注意,ftpusers檔案是一個黑名單,裡面的使用者不可以登入ftp,當然,也可以程式設計白名單,修改/etc/pam.d/vsftpd,將deny修改為allow(沒有試過,據說這個可以,但是意義不大),白名單可以使用user_list檔案# When "listen" directive is enabled, vsftpd runs in standalone mode and # listens on IPv4 sockets. This directive cannot be used in conjunction # with the listen_ipv6 directive. listen=YES # # This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6 # sockets, you must run two copies of vsftpd with two configuration files. # Make sure, that one of the listen options is commented !! #listen_ipv6=YES
auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed
二:新增使用者
1.新增使用者,使用 -d用來指向主目錄 最後加上使用者名稱
[root@localhost vsftpd]# useradd -d /home/test test
[root@localhost vsftpd]# passwd test //修改密碼,可能修改密碼的時候會無法通過linux校驗,root使用者無視就好,連續輸入兩次
2.修改使用者的許可權[root@localhost vsftpd]# usermod -s /sbin/nologin test //使用者無法通過xshall登入(如果想使用該使用者通過xftp管理的,可以不設定)注:筆者在修改為這個狀態以後,無法上傳檔案,也無法登陸,求解答。
[root@localhost vsftpd]# usermod -d /usr/test test //修改使用者主目錄到user/test
[root@localhost vsftpd]# usermod -s /bin/bash test //還原狀態
使用者許可權可以修改配置檔案,不過還沒有試過,以後補充
[root@localhost vsftpd]# vi /etc/shells
三:異常處理
1.500,在linux中輸入一條命令,原因未知,之後再看
500 OOPS: cannot change directory:/home/test
500 OOPS: priv_sock_get_cmd
命令如下:
[root@localhost vsftpd]# setsebool -P ftp_home_dir 1
2.530530 Permission denied.
確認黑名單中是否有你的使用者
530 Login incorrect.
我的原因是許可權給了/sbin/nologin ,將其調回預設就好了