local_umask=022<\/strong>\r\n5 dirmessage_enable=YES\r\n6 xferlog_enable=YES\r\n7 connect_from_port_20=YES\r\n8 xferlog_std_format=YES\r\n9 listen=NO\r\n10 listen_ipv6=YES\r\n11 pam_service_name=vsftpd\r\n12 userlist_enable=YES\r\n13 tcp_wrappers=YES<\/pre>\n\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u6b63\u786e\u586b\u5199\u53c2\u6570\uff0c\u7136\u540e\u4fdd\u5b58\u5e76\u9000\u51fa\u3002\u8fd8\u9700\u8981\u91cd\u542fvsftpd\u670d\u52a1\u7a0b\u5e8f\uff0c\u8ba9\u65b0\u7684\u914d\u7f6e\u53c2\u6570\u751f\u6548\u3002\u5728\u6267\u884c\u5b8c\u4e0a\u4e00\u4e2a\u5b9e\u9a8c\u540e\u8fd8\u539f\u4e86\u865a\u62df\u673a\u7684\u8bfb\u8005\uff0c\u8fd8\u9700\u8981\u5c06\u914d\u7f6e\u597d\u7684\u670d\u52a1\u6dfb\u52a0\u5230\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff0c\u4ee5\u4fbf\u5728\u7cfb\u7edf\u91cd\u542f\u81ea\u540e\u4f9d\u7136\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528vsftpd\u670d\u52a1\u3002<\/p>\n
[root@linuxprobe ~]# systemctl restart vsftpd\r\n[root@linuxprobe ~]# systemctl enable vsftpd\r\n ln -s '\/usr\/lib\/systemd\/system\/vsftpd.service' '\/etc\/systemd\/system\/multi-user.target.wants\/vsftpd.service<\/pre>\n\u6309\u7406\u6765\u8bb2\uff0c\u73b0\u5728\u5df2\u7ecf\u5b8c\u5168\u53ef\u4ee5\u672c\u5730\u7528\u6237\u7684\u8eab\u4efd\u767b\u5f55FTP\u670d\u52a1\u5668\u4e86\u3002\u4f46\u662f\u5728\u4f7f\u7528root\u7ba1\u7406\u5458\u767b\u5f55\u540e\uff0c\u7cfb\u7edf\u63d0\u793a\u5982\u4e0b\u7684\u9519\u8bef\u4fe1\u606f\uff1a<\/p>\n
[root@linuxprobe ~]# ftp 192.168.10.10\r\nConnected to 192.168.10.10 (192.168.10.10).\r\n220 (vsFTPd 3.0.2)\r\nName (192.168.10.10:root): root<\/strong>\r\n530 Permission denied.\r\nLogin failed.\r\nftp><\/pre>\n\u53ef\u89c1\uff0c\u5728\u6211\u4eec\u8f93\u5165root\u7ba1\u7406\u5458\u7684\u5bc6\u7801\u4e4b\u524d\uff0c\u5c31\u5df2\u7ecf\u88ab\u7cfb\u7edf\u62d2\u7edd\u8bbf\u95ee\u4e86\u3002\u8fd9\u662f\u56e0\u4e3avsftpd\u670d\u52a1\u7a0b\u5e8f\u6240\u5728\u7684\u76ee\u5f55\u4e2d\u9ed8\u8ba4\u5b58\u653e\u7740\u4e24\u4e2a\u540d\u4e3a\u201c\u7528\u6237\u540d\u5355\u201d\u7684\u6587\u4ef6\uff08ftpusers\u548cuser_list\uff09\u3002\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u5df2\u770b\u8fc7\u4e00\u90e8\u65e5\u672c\u7535\u5f71\u201c\u6b7b\u4ea1\u7b14\u8bb0\u201d\uff08\u5218\u9044\u8001\u5e08\u5728\u4e0a\u5b66\u671f\u95f4\u7684\u6700\u7231\uff09\uff0c\u91cc\u9762\u5c31\u63d0\u5230\u6709\u4e00\u4e2a\u9ed1\u8272\u5c01\u76ae\u7684\u5c0f\u672c\u5b50\uff0c\u53ea\u8981\u5c06\u522b\u4eba\u7684\u540d\u5b57\u5199\u8fdb\u53bb\uff0c\u8fd9\u4eba\u5c31\u4f1a\u6302\u6389\u3002vsftpd\u670d\u52a1\u7a0b\u5e8f\u76ee\u5f55\u4e2d\u7684\u8fd9\u4e24\u4e2a\u6587\u4ef6\u4e5f\u6709\u7c7b\u4f3c\u7684\u529f\u80fd\u2014\u53ea\u8981\u91cc\u9762\u5199\u6709\u67d0\u4f4d\u7528\u6237\u7684\u540d\u5b57\uff0c\u5c31\u4e0d\u518d\u5141\u8bb8\u8fd9\u4f4d\u7528\u6237\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n
[root@linuxprobe ~]# cat \/etc\/vsftpd\/user_list \r\n1 # vsftpd userlist\r\n2 # If userlist_deny=NO, only allow users in this file\r\n3 # If userlist_deny=YES (default), never allow users in this file, and\r\n4 # do not even prompt for a password.\r\n5 # Note that the default vsftpd pam config also checks \/etc\/vsftpd\/ftpusers\r\n6 # for users that are denied.\r\n7 root<\/strong><\/del>\r\n8 bin\r\n9 daemon\r\n10 adm\r\n11 lp\r\n12 sync\r\n13 shutdown\r\n14 halt\r\n15 mail\r\n16 news\r\n17 uucp\r\n18 operator\r\n19 games\r\n20 nobody\r\n[root@linuxprobe ~]# cat \/etc\/vsftpd\/ftpusers \r\n# Users that are not allowed to login via ftp\r\n1 root<\/strong><\/del>\r\n2 bin\r\n3 daemon\r\n4 adm\r\n5 lp\r\n6 sync\r\n7 shutdown\r\n8 halt\r\n9 mail\r\n10 news\r\n11 uucp\r\n12 operator\r\n13 games\r\n14 nobody<\/pre>\n\u679c\u7136\u5982\u6b64\uff01vsftpd\u670d\u52a1\u7a0b\u5e8f\u4e3a\u4e86\u4fdd\u8bc1\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u800c\u9ed8\u8ba4\u7981\u6b62\u4e86root\u7ba1\u7406\u5458\u548c\u5927\u591a\u6570\u7cfb\u7edf\u7528\u6237\u7684\u767b\u5f55\u884c\u4e3a\uff0c\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u5730\u907f\u514d\u9ed1\u5ba2\u901a\u8fc7FTP\u670d\u52a1\u5bf9root\u7ba1\u7406\u5458\u5bc6\u7801\u8fdb\u884c\u66b4\u529b\u7834\u89e3\u3002\u5982\u679c\u60a8\u786e\u8ba4\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4f7f\u7528root\u7ba1\u7406\u5458\u4e0d\u4f1a\u5bf9\u7cfb\u7edf\u5b89\u5168\u4ea7\u751f\u5f71\u54cd\uff0c\u53ea\u9700\u6309\u7167\u4e0a\u9762\u7684\u63d0\u793a\u5220\u9664\u6389root\u7528\u6237\u540d\u5373\u53ef\u3002\u6211\u4eec\u4e5f\u53ef\u4ee5\u9009\u62e9ftpusers\u548cuser_list\u6587\u4ef6\u4e2d\u6ca1\u6709\u7684\u4e00\u4e2a\u666e\u901a\u7528\u6237\u5c1d\u8bd5\u767b\u5f55FTP\u670d\u52a1\u5668\uff1a<\/p>\n
[root@linuxprobe ~]# ftp 192.168.10.10 \r\nConnected to 192.168.10.10 (192.168.10.10).\r\n220 (vsFTPd 3.0.2)\r\nName (192.168.10.10:root): linuxprobe<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u8f93\u5165\u8be5\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> mkdir files\r\n550 Create directory operation failed.\r\n<\/pre>\n\u5728\u91c7\u7528\u672c\u5730\u7528\u6237\u6a21\u5f0f\u767b\u5f55FTP\u670d\u52a1\u5668\u540e\uff0c\u9ed8\u8ba4\u8bbf\u95ee\u7684\u662f\u8be5\u7528\u6237\u7684\u5bb6\u76ee\u5f55\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u8bbf\u95ee\u7684\u662f\/home\/linuxprobe\u76ee\u5f55\u3002\u800c\u4e14\u8be5\u76ee\u5f55\u7684\u9ed8\u8ba4\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u90fd\u662f\u8be5\u7528\u6237\u81ea\u5df1\uff0c\u56e0\u6b64\u4e0d\u5b58\u5728\u5199\u5165\u6743\u9650\u4e0d\u8db3\u7684\u60c5\u51b5\u3002\u4f46\u662f\u5f53\u524d\u7684\u64cd\u4f5c\u4ecd\u7136\u88ab\u62d2\u7edd\uff0c\u662f\u56e0\u4e3a\u6211\u4eec\u521a\u624d\u5c06\u865a\u62df\u673a\u7cfb\u7edf\u8fd8\u539f\u5230\u6700\u521d\u7684\u72b6\u6001\u4e86\u3002\u4e3a\u6b64\uff0c\u9700\u8981\u518d\u6b21\u5f00\u542fSELinux\u57df\u4e2d\u5bf9FTP\u670d\u52a1\u7684\u5141\u8bb8\u7b56\u7565\uff1a<\/p>\n
[root@linuxprobe ~]# getsebool -a | grep ftp\r\nftp_home_dir --> off\r\nftpd_anon_write --> off\r\nftpd_connect_all_unreserved --> off\r\nftpd_connect_db --> off\r\nftpd_full_access --> off<\/strong>\r\nftpd_use_cifs --> off\r\nftpd_use_fusefs --> off\r\nftpd_use_nfs --> off\r\nftpd_use_passive_mode --> off\r\nhttpd_can_connect_ftp --> off\r\nhttpd_enable_ftp_server --> off\r\nsftpd_anon_write --> off\r\nsftpd_enable_homedirs --> off\r\nsftpd_full_access --> off\r\nsftpd_write_ssh_home --> off\r\ntftp_anon_write --> off\r\ntftp_home_dir --> off\r\n[root@linuxprobe ~]# setsebool -P ftpd_full_access=on<\/pre>\n\u5218\u9044\u8001\u5e08\u518d\u5570\u55e6\u51e0\u53e5\u3002\u5728\u5b9e\u9a8c\u8bfe\u7a0b\u548c\u751f\u4ea7\u73af\u5883\u4e2d\u8bbe\u7f6eSELinux\u57df\u7b56\u7565\u65f6\uff0c\u4e00\u5b9a\u8bb0\u5f97\u6dfb\u52a0-P\u53c2\u6570\uff0c\u5426\u5219\u670d\u52a1\u5668\u5728\u91cd\u542f\u540e\u5c31\u4f1a\u6309\u7167\u539f\u6709\u7684\u7b56\u7565\u8fdb\u884c\u63a7\u5236\uff0c\u4ece\u800c\u5bfc\u81f4\u914d\u7f6e\u8fc7\u7684\u670d\u52a1\u65e0\u6cd5\u4f7f\u7528\u3002<\/p>\n
\u5728\u914d\u7f6e\u59a5\u5f53\u540e\u518d\u4f7f\u7528\u672c\u5730\u7528\u6237\u5c1d\u8bd5\u767b\u5f55\u4e0bFTP\u670d\u52a1\u5668\uff0c\u5206\u522b\u6267\u884c\u6587\u4ef6\u7684\u521b\u5efa\u3001\u91cd\u547d\u540d\u53ca\u5220\u9664\u7b49\u547d\u4ee4\u3002\u64cd\u4f5c\u5747\u6210\u529f\uff01<\/p>\n
[root@linuxprobe ~]# ftp 192.168.10.10\r\nConnected to 192.168.10.10 (192.168.10.10).\r\n220 (vsFTPd 3.0.2)\r\nName (192.168.10.10:root): linuxprobe<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u8f93\u5165\u8be5\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> mkdir files\r\n257 \"\/home\/linuxprobe\/files\" created\r\nftp> rename files database\r\n350 Ready for RNTO.\r\n250 Rename successful.\r\nftp> rmdir database\r\n250 Remove directory operation successful.\r\nftp> exit\r\n221 Goodbye.\r\n<\/pre>\n\u8bf7\u6ce8\u610f:<\/span>\u5f53\u60a8\u5b8c\u6210\u672c\u5b9e\u9a8c\u540e\u8bf7\u8fd8\u539f\u865a\u62df\u673a\u5feb\u7167\u518d\u8fdb\u884c\u4e0b\u4e00\u4e2a\u5b9e\u9a8c\uff0c\u5426\u5219\u53ef\u80fd\u5bfc\u81f4\u914d\u7f6e\u6587\u4ef6\u51b2\u7a81\u800c\u62a5\u9519\u3002<\/strong><\/p>\n11.2.3 \u865a\u62df\u7528\u6237\u6a21\u5f0f<\/strong><\/span><\/h6>\n\u6211\u4eec\u6700\u540e\u8bb2\u89e3\u7684\u865a\u62df\u7528\u6237\u6a21\u5f0f\u662f\u8fd9\u4e09\u79cd\u6a21\u5f0f\u4e2d\u6700\u5b89\u5168\u7684\u4e00\u79cd\u8ba4\u8bc1\u6a21\u5f0f\uff0c\u5f53\u7136\uff0c\u56e0\u4e3a\u5b89\u5168\u6027\u8f83\u4e4b\u4e8e\u524d\u9762\u4e24\u79cd\u6a21\u5f0f\u6709\u4e86\u63d0\u5347\uff0c\u6240\u4ee5\u914d\u7f6e\u6d41\u7a0b\u4e5f\u4f1a\u7a0d\u5fae\u590d\u6742\u4e00\u4e9b\u3002<\/p>\n
\u7b2c1\u6b65<\/strong>\uff1a\u521b\u5efa\u7528\u4e8e\u8fdb\u884cFTP\u8ba4\u8bc1\u7684\u7528\u6237\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u5176\u4e2d\u5947\u6570\u884c\u4e3a\u8d26\u6237\u540d\uff0c\u5076\u6570\u884c\u4e3a\u5bc6\u7801\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u5206\u522b\u521b\u5efa\u51fazhangsan\u548clisi\u4e24\u4e2a\u7528\u6237\uff0c\u5bc6\u7801\u5747\u4e3aredhat\uff1a<\/p>\n[root@linuxprobe ~]# cd \/etc\/vsftpd\/\r\n[root@linuxprobe vsftpd]# vim vuser.list<\/strong>\r\nzhangsan\r\nredhat\r\nlisi\r\nredhat<\/pre>\n\u4f46\u662f\uff0c\u660e\u6587\u4fe1\u606f\u65e2\u4e0d\u5b89\u5168\uff0c\u4e5f\u4e0d\u7b26\u5408\u8ba9vsftpd\u670d\u52a1\u7a0b\u5e8f\u76f4\u63a5\u52a0\u8f7d\u7684\u683c\u5f0f\uff0c\u56e0\u6b64\u9700\u8981\u4f7f\u7528db_load\u547d\u4ee4\u7528\u54c8\u5e0c\uff08hash\uff09\u7b97\u6cd5\u5c06\u539f\u59cb\u7684\u660e\u6587\u4fe1\u606f\u6587\u4ef6\u8f6c\u6362\u6210\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u5e76\u4e14\u964d\u4f4e\u6570\u636e\u5e93\u6587\u4ef6\u7684\u6743\u9650\uff08\u907f\u514d\u5176\u4ed6\u4eba\u770b\u5230\u6570\u636e\u5e93\u6587\u4ef6\u7684\u5185\u5bb9\uff09\uff0c\u7136\u540e\u518d\u628a\u539f\u59cb\u7684\u660e\u6587\u4fe1\u606f\u6587\u4ef6\u5220\u9664\u3002<\/p>\n
[root@linuxprobe vsftpd]# db_load -T -t hash -f vuser.list vuser.db\r\n[root@linuxprobe vsftpd]# file vuser.db\r\nvuser.db: Berkeley DB (Hash, version 9, native byte-order)\r\n[root@linuxprobe vsftpd]# chmod 600 vuser.db\r\n[root@linuxprobe vsftpd]# rm -f vuser.list\r\n<\/pre>\n\u7b2c2\u6b65<\/strong>\uff1a\u521b\u5efavsftpd\u670d\u52a1\u7a0b\u5e8f\u7528\u4e8e\u5b58\u50a8\u6587\u4ef6\u7684\u6839\u76ee\u5f55\u4ee5\u53ca\u865a\u62df\u7528\u6237\u6620\u5c04\u7684\u7cfb\u7edf\u672c\u5730\u7528\u6237\u3002FTP\u670d\u52a1\u7528\u4e8e\u5b58\u50a8\u6587\u4ef6\u7684\u6839\u76ee\u5f55\u6307\u7684\u662f\uff0c\u5f53\u865a\u62df\u7528\u6237\u767b\u5f55\u540e\u6240\u8bbf\u95ee\u7684\u9ed8\u8ba4\u4f4d\u7f6e\u3002<\/p>\n\u7531\u4e8eLinux\u7cfb\u7edf\u4e2d\u7684\u6bcf\u4e00\u4e2a\u6587\u4ef6\u90fd\u6709\u6240\u6709\u8005\u3001\u6240\u5c5e\u7ec4\u5c5e\u6027\uff0c\u4f8b\u5982\u4f7f\u7528\u865a\u62df\u8d26\u6237\u201c\u5f20\u4e09\u201d\u65b0\u5efa\u4e86\u4e00\u4e2a\u6587\u4ef6\uff0c\u4f46\u662f\u7cfb\u7edf\u4e2d\u627e\u4e0d\u5230\u8d26\u6237\u201c\u5f20\u4e09\u201d\uff0c\u5c31\u4f1a\u5bfc\u81f4\u8fd9\u4e2a\u6587\u4ef6\u7684\u6743\u9650\u51fa\u73b0\u9519\u8bef\u3002\u4e3a\u6b64\uff0c\u9700\u8981\u518d\u521b\u5efa\u4e00\u4e2a\u53ef\u4ee5\u6620\u5c04\u5230\u865a\u62df\u7528\u6237\u7684\u7cfb\u7edf\u672c\u5730\u7528\u6237\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f\u8ba9\u865a\u62df\u7528\u6237\u9ed8\u8ba4\u767b\u5f55\u5230\u4e0e\u4e4b\u6709\u6620\u5c04\u5173\u7cfb\u7684\u8fd9\u4e2a\u7cfb\u7edf\u672c\u5730\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u4e2d\uff0c\u865a\u62df\u7528\u6237\u521b\u5efa\u7684\u6587\u4ef6\u7684\u5c5e\u6027\u4e5f\u90fd\u5f52\u5c5e\u4e8e\u8fd9\u4e2a\u7cfb\u7edf\u672c\u5730\u7528\u6237\uff0c\u4ece\u800c\u907f\u514dLinux\u7cfb\u7edf\u65e0\u6cd5\u5904\u7406\u865a\u62df\u7528\u6237\u6240\u521b\u5efa\u6587\u4ef6\u7684\u5c5e\u6027\u6743\u9650\u3002<\/p>\n
\u4e3a\u4e86\u65b9\u4fbf\u7ba1\u7406FTP\u670d\u52a1\u5668\u4e0a\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u628a\u8fd9\u4e2a\u7cfb\u7edf\u672c\u5730\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u8bbe\u7f6e\u4e3a\/var\u76ee\u5f55\uff08\u8be5\u76ee\u5f55\u7528\u6765\u5b58\u653e\u7ecf\u5e38\u53d1\u751f\u6539\u53d8\u7684\u6570\u636e\uff09\u3002\u5e76\u4e14\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u6211\u4eec\u5c06\u8fd9\u4e2a\u7cfb\u7edf\u672c\u5730\u7528\u6237\u8bbe\u7f6e\u4e3a\u4e0d\u5141\u8bb8\u767b\u5f55FTP\u670d\u52a1\u5668\uff0c\u8fd9\u4e0d\u4f1a\u5f71\u54cd\u865a\u62df\u7528\u6237\u767b\u5f55\uff0c\u800c\u4e14\u8fd8\u53ef\u4ee5\u907f\u514d\u9ed1\u5ba2\u901a\u8fc7\u8fd9\u4e2a\u7cfb\u7edf\u672c\u5730\u7528\u6237\u8fdb\u884c\u767b\u5f55\u3002<\/p>\n
[root@linuxprobe ~]# useradd -d \/var\/ftproot -s \/sbin\/nologin virtual\r\n[root@linuxprobe ~]# ls -ld \/var\/ftproot\/\r\ndrwx------. 3 virtual virtual 74 Jul 14 17:50 \/var\/ftproot\/\r\n[root@linuxprobe ~]# chmod -Rf 755 \/var\/ftproot\/\r\n<\/pre>\n\u7b2c3\u6b65<\/strong>\uff1a\u5efa\u7acb\u7528\u4e8e\u652f\u6301\u865a\u62df\u7528\u6237\u7684PAM\u6587\u4ef6\u3002<\/p>\nPAM\uff08\u53ef\u63d2\u62d4\u8ba4\u8bc1\u6a21\u5757\uff09\u662f\u4e00\u79cd\u8ba4\u8bc1\u673a\u5236\uff0c\u901a\u8fc7\u4e00\u4e9b\u52a8\u6001\u94fe\u63a5\u5e93\u548c\u7edf\u4e00\u7684API\u628a\u7cfb\u7edf\u63d0\u4f9b\u7684\u670d\u52a1\u4e0e\u8ba4\u8bc1\u65b9\u5f0f\u5206\u5f00\uff0c\u4f7f\u5f97\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u7075\u6d3b\u8c03\u6574\u670d\u52a1\u7a0b\u5e8f\u7684\u4e0d\u540c\u8ba4\u8bc1\u65b9\u5f0f\u3002\u8981\u60f3\u628aPAM\u529f\u80fd\u548c\u4f5c\u7528\u5b8c\u5168\u8bb2\u900f\uff0c\u81f3\u5c11\u8981\u4e00\u4e2a\u7ae0\u8282\u7684\u7bc7\u5e45\u624d\u53ef\u4ee5\uff08\u5bf9\u8be5\u4e3b\u9898\u611f\u5174\u8da3\u7684\u8bfb\u8005\u656c\u8bf7\u5173\u6ce8\u672c\u4e66\u7684\u8fdb\u9636\u7bc7\uff0c\u91cc\u9762\u4f1a\u8be6\u7ec6\u8bb2\u89e3PAM\uff09\u3002<\/p>\n
\u901a\u4fd7\u6765\u8bb2\uff0cPAM\u662f\u4e00\u7ec4\u5b89\u5168\u673a\u5236\u7684\u6a21\u5757\uff0c\u7cfb\u7edf\u7ba1\u7406\u5458\u53ef\u4ee5\u7528\u6765\u8f7b\u6613\u5730\u8c03\u6574\u670d\u52a1\u7a0b\u5e8f\u7684\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u800c\u4e0d\u5fc5\u5bf9\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u4efb\u4f55\u4fee\u6539\u3002PAM\u91c7\u53d6\u4e86\u5206\u5c42\u8bbe\u8ba1\uff08\u5e94\u7528\u7a0b\u5e8f\u5c42\u3001\u5e94\u7528\u63a5\u53e3\u5c42\u3001\u9274\u522b\u6a21\u5757\u5c42\uff09\u7684\u601d\u60f3\uff0c\u5176\u7ed3\u6784\u5982\u56fe11-2\u6240\u793a\u3002<\/p>\n
<\/div>\n
\u56fe11-2\u00a0 PAM\u7684\u5206\u5c42\u8bbe\u8ba1\u7ed3\u6784<\/p>\n
\u65b0\u5efa\u4e00\u4e2a\u7528\u4e8e\u865a\u62df\u7528\u6237\u8ba4\u8bc1\u7684PAM\u6587\u4ef6vsftpd.vu\uff0c\u5176\u4e2dPAM\u6587\u4ef6\u5185\u7684\u201cdb=\u201d\u53c2\u6570\u4e3a\u4f7f\u7528db_load\u547d\u4ee4\u751f\u6210\u7684\u8d26\u6237\u5bc6\u7801\u6570\u636e\u5e93\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u4f46\u4e0d\u7528\u5199\u6570\u636e\u5e93\u6587\u4ef6\u7684\u540e\u7f00\uff1a<\/p>\n
[root@linuxprobe ~]# vim \/etc\/pam.d\/vsftpd.vu\r\nauth\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 required\u00a0\u00a0\u00a0\u00a0 pam_userdb.so db=\/etc\/vsftpd\/vuser\r\naccount\u00a0\u00a0\u00a0 required\u00a0\u00a0\u00a0\u00a0 pam_userdb.so db=\/etc\/vsftpd\/vuser\r\n<\/pre>\n\u7b2c4\u6b65<\/strong>\uff1a\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u901a\u8fc7pam_service_name\u53c2\u6570\u5c06PAM\u8ba4\u8bc1\u6587\u4ef6\u7684\u540d\u79f0\u4fee\u6539\u4e3avsftpd.vu\uff0cPAM\u4f5c\u4e3a\u5e94\u7528\u7a0b\u5e8f\u5c42\u4e0e\u9274\u522b\u6a21\u5757\u5c42\u7684\u8fde\u63a5\u7ebd\u5e26\uff0c\u53ef\u4ee5\u8ba9\u5e94\u7528\u7a0b\u5e8f\u6839\u636e\u9700\u6c42\u7075\u6d3b\u5730\u5728\u81ea\u8eab\u63d2\u5165\u6240\u9700\u7684\u9274\u522b\u529f\u80fd\u6a21\u5757\u3002\u5f53\u5e94\u7528\u7a0b\u5e8f\u9700\u8981PAM\u8ba4\u8bc1\u65f6\uff0c\u5219\u9700\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5b9a\u4e49\u8d1f\u8d23\u8ba4\u8bc1\u7684PAM\u914d\u7f6e\u6587\u4ef6\uff0c\u5b9e\u73b0\u6240\u9700\u7684\u8ba4\u8bc1\u529f\u80fd\u3002<\/p>\n\u4f8b\u5982\uff0c\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u9ed8\u8ba4\u5c31\u5e26\u6709\u53c2\u6570pam_service_name=vsftpd\uff0c\u8868\u793a\u767b\u5f55FTP\u670d\u52a1\u5668\u65f6\u662f\u6839\u636e\/etc\/pam.d\/vsftpd\u6587\u4ef6\u8fdb\u884c\u5b89\u5168\u8ba4\u8bc1\u7684\u3002\u73b0\u5728\u6211\u4eec\u8981\u505a\u7684\u5c31\u662f\u628avsftpd\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u539f\u6709\u7684PAM\u8ba4\u8bc1\u6587\u4ef6vsftpd\u4fee\u6539\u4e3a\u65b0\u5efa\u7684vsftpd.vu\u6587\u4ef6\u5373\u53ef\u3002\u8be5\u64cd\u4f5c\u4e2d\u7528\u5230\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u5982\u886811-4\u6240\u793a\u3002<\/p>\n
\u886811-4\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u5229\u7528PAM\u6587\u4ef6\u8fdb\u884c\u8ba4\u8bc1\u65f6\u4f7f\u7528\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n
\n\n\n\u53c2\u6570<\/td>\n | \u4f5c\u7528<\/td>\n<\/tr>\n |
\nanonymous_enable=NO<\/td>\n | \u7981\u6b62\u533f\u540d\u5f00\u653e\u6a21\u5f0f<\/td>\n<\/tr>\n |
\nlocal_enable=YES<\/td>\n | \u5141\u8bb8\u672c\u5730\u7528\u6237\u6a21\u5f0f<\/td>\n<\/tr>\n |
\nguest_enable=YES<\/td>\n | \u5f00\u542f\u865a\u62df\u7528\u6237\u6a21\u5f0f<\/td>\n<\/tr>\n |
\nguest_username=virtual<\/td>\n | \u6307\u5b9a\u865a\u62df\u7528\u6237\u8d26\u6237<\/td>\n<\/tr>\n |
\npam_service_name=vsftpd.vu<\/td>\n | \u6307\u5b9aPAM\u6587\u4ef6<\/td>\n<\/tr>\n |
\nallow_writeable_chroot=YES<\/td>\n | \u5141\u8bb8\u5bf9\u7981\u9522\u7684FTP\u6839\u76ee\u5f55\u6267\u884c\u5199\u5165\u64cd\u4f5c\uff0c\u800c\u4e14\u4e0d\u62d2\u7edd\u7528\u6237\u7684\u767b\u5f55\u8bf7\u6c42<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n [root@linuxprobe ~]# vim \/etc\/vsftpd\/vsftpd.conf\r\n1 anonymous_enable=NO<\/strong>\r\n2 local_enable=YES<\/strong>\r\n3 guest_enable=YES<\/strong>\r\n4 guest_username=virtual<\/strong>\r\n5 allow_writeable_chroot=YES<\/strong>\r\n6 write_enable=YES\r\n7 local_umask=022\r\n8 dirmessage_enable=YES\r\n9 xferlog_enable=YES\r\n10 connect_from_port_20=YES\r\n11 xferlog_std_format=YES\r\n12 listen=NO\r\n13 listen_ipv6=YES\r\n14 pam_service_name=vsftpd.vu<\/strong>\r\n15 userlist_enable=YES\r\n16 tcp_wrappers=YES<\/pre>\n\u7b2c5\u6b65<\/strong>\uff1a\u4e3a\u865a\u62df\u7528\u6237\u8bbe\u7f6e\u4e0d\u540c\u7684\u6743\u9650\u3002\u867d\u7136\u8d26\u6237zhangsan\u548clisi\u90fd\u662f\u7528\u4e8evsftpd\u670d\u52a1\u7a0b\u5e8f\u8ba4\u8bc1\u7684\u865a\u62df\u8d26\u6237\uff0c\u4f46\u662f\u6211\u4eec\u4f9d\u7136\u60f3\u5bf9\u8fd9\u4e24\u4eba\u8fdb\u884c\u533a\u522b\u5bf9\u5f85\u3002\u6bd4\u5982\uff0c\u5141\u8bb8\u5f20\u4e09\u4e0a\u4f20\u3001\u521b\u5efa\u3001\u4fee\u6539\u3001\u67e5\u770b\u3001\u5220\u9664\u6587\u4ef6\uff0c\u53ea\u5141\u8bb8\u674e\u56db\u67e5\u770b\u6587\u4ef6\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7vsftpd\u670d\u52a1\u7a0b\u5e8f\u6765\u5b9e\u73b0\u3002\u53ea\u9700\u65b0\u5efa\u4e00\u4e2a\u76ee\u5f55\uff0c\u5728\u91cc\u9762\u5206\u522b\u521b\u5efa\u4e24\u4e2a\u4ee5zhangsan\u548clisi\u547d\u540d\u7684\u6587\u4ef6\uff0c\u5176\u4e2d\u5728\u540d\u4e3azhangsan\u7684\u6587\u4ef6\u4e2d\u5199\u5165\u5141\u8bb8\u7684\u76f8\u5173\u6743\u9650\uff08\u4f7f\u7528\u533f\u540d\u7528\u6237\u7684\u53c2\u6570\uff09\uff1a<\/p>\n[root@linuxprobe ~]# mkdir \/etc\/vsftpd\/vusers_dir\/\r\n[root@linuxprobe ~]# cd \/etc\/vsftpd\/vusers_dir\/\r\n[root@linuxprobe vusers_dir]# touch lisi\r\n[root@linuxprobe vusers_dir]# vim zhangsan\r\nanon_upload_enable=YES\r\nanon_mkdir_write_enable=YES\r\nanon_other_write_enable=YES<\/pre>\n\u7136\u540e\u518d\u6b21\u4fee\u6539vsftpd\u4e3b\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u8fc7\u6dfb\u52a0user_config_dir\u53c2\u6570\u6765\u5b9a\u4e49\u8fd9\u4e24\u4e2a\u865a\u62df\u7528\u6237\u4e0d\u540c\u6743\u9650\u7684\u914d\u7f6e\u6587\u4ef6\u6240\u5b58\u653e\u7684\u8def\u5f84\u3002\u4e3a\u4e86\u8ba9\u4fee\u6539\u540e\u7684\u53c2\u6570\u7acb\u5373\u751f\u6548\uff0c\u9700\u8981\u91cd\u542fvsftpd\u670d\u52a1\u7a0b\u5e8f\u5e76\u5c06\u8be5\u670d\u52a1\u6dfb\u52a0\u5230\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff1a<\/p>\n [root@linuxprobe ~]# vim \/etc\/vsftpd\/vsftpd.conf\r\nanonymous_enable=NO\r\nlocal_enable=YES\r\nguest_enable=YES\r\nguest_username=virtual\r\nallow_writeable_chroot=YES\r\nwrite_enable=YES\r\nlocal_umask=022\r\ndirmessage_enable=YES\r\nxferlog_enable=YES\r\nconnect_from_port_20=YES\r\nxferlog_std_format=YES\r\nlisten=NO\r\nlisten_ipv6=YES\r\npam_service_name=vsftpd.vu\r\nuserlist_enable=YES\r\ntcp_wrappers=YES\r\nuser_config_dir=\/etc\/vsftpd\/vusers_dir\r\n<\/strong>[root@linuxprobe ~]# systemctl restart vsftpd\r\n[root@linuxprobe ~]# systemctl enable vsftpd\r\n ln -s '\/usr\/lib\/systemd\/system\/vsftpd.service' '\/etc\/systemd\/system\/multi-user.target.wants\/vsftpd.service\r\n<\/pre>\n\u7b2c6\u6b65<\/strong>\uff1a\u8bbe\u7f6eSELinux\u57df\u5141\u8bb8\u7b56\u7565\uff0c\u7136\u540e\u4f7f\u7528\u865a\u62df\u7528\u6237\u6a21\u5f0f\u767b\u5f55FTP\u670d\u52a1\u5668\u3002\u76f8\u4fe1\u5927\u5bb6\u53ef\u4ee5\u731c\u5230\uff0cSELinux\u4f1a\u7ee7\u7eed\u6765\u6363\u4e71\u3002\u6240\u4ee5\uff0c\u5148\u6309\u7167\u524d\u9762\u5b9e\u9a8c\u4e2d\u7684\u6b65\u9aa4\u5f00\u542fSELinux\u57df\u7684\u5141\u8bb8\u7b56\u7565\uff0c\u4ee5\u514d\u518d\u6b21\u51fa\u73b0\u64cd\u4f5c\u5931\u8d25\u7684\u60c5\u51b5\uff1a<\/p>\n[root@linuxprobe ~]# getsebool -a | grep ftp\r\nftp_home_dir \u2013> off\r\nftpd_anon_write \u2013> off\r\nftpd_connect_all_unreserved \u2013> off\r\nftpd_connect_db \u2013> off\r\nftpd_full_access \u2013> off<\/strong>\r\nftpd_use_cifs \u2013> off\r\nftpd_use_fusefs \u2013> off\r\nftpd_use_nfs \u2013> off\r\nftpd_use_passive_mode \u2013> off\r\nhttpd_can_connect_ftp \u2013> off\r\nhttpd_enable_ftp_server \u2013> off\r\nsftpd_anon_write \u2013> off\r\nsftpd_enable_homedirs \u2013> off\r\nsftpd_full_access \u2013> off\r\nsftpd_write_ssh_home \u2013> off\r\ntftp_anon_write \u2013> off\r\ntftp_home_dir \u2013> off\r\n[root@linuxprobe ~]# setsebool -P ftpd_full_access=on<\/pre>\n\u6b64\u65f6\uff0c\u4e0d\u4f46\u53ef\u4ee5\u4f7f\u7528\u865a\u62df\u7528\u6237\u6a21\u5f0f\u6210\u529f\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\uff0c\u8fd8\u53ef\u4ee5\u5206\u522b\u4f7f\u7528\u8d26\u6237zhangsan\u548clisi\u6765\u68c0\u9a8c\u4ed6\u4eec\u7684\u6743\u9650\u3002\u5f53\u7136\uff0c\u8bfb\u8005\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u4e00\u5b9a\u8981\u6839\u636e\u771f\u5b9e\u9700\u6c42\u6765\u7075\u6d3b\u914d\u7f6e\u53c2\u6570\uff0c\u4e0d\u8981\u7167\u642c\u8fd9\u91cc\u7684\u5b9e\u9a8c\u64cd\u4f5c\u3002<\/p>\n [root@linuxprobe ~]# ftp 192.168.10.10\r\nConnected to 192.168.10.10 (192.168.10.10).\r\n220 (vsFTPd 3.0.2)\r\nName (192.168.10.10:root): lisi<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u8f93\u5165\u865a\u62df\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> mkdir files\r\n550 Permission denied.<\/span>\r\nftp> exit\r\n221 Goodbye.\r\n[root@linuxprobe ~]# ftp 192.168.10.10\r\nConnected to 192.168.10.10 (192.168.10.10).\r\n220 (vsFTPd 3.0.2)\r\nName (192.168.10.10:root): zhangsan<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u8f93\u5165\u865a\u62df\u7528\u6237\u7684\u5bc6\u7801<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> mkdir files<\/strong>\r\n257 \"\/files\" created\r\nftp> rename files database<\/strong>\r\n350 Ready for RNTO.\r\n250 Rename successful.\r\nftp> rmdir database<\/strong>\r\n250 Remove directory operation successful.\r\nftp> exit\r\n221 Goodbye.\r\n<\/pre>\n |