{"id":1443,"date":"2022-05-26T09:44:28","date_gmt":"2022-05-26T01:44:28","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=1443"},"modified":"2022-05-26T21:06:41","modified_gmt":"2022-05-26T13:06:41","slug":"chapter-11","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/chapter-11.html","title":{"rendered":"\u7b2c11\u7ae0 \u4f7f\u7528Vsftpd\u670d\u52a1\u4f20\u8f93\u6587\u4ef6\u3002"},"content":{"rendered":"

👇\u672c\u7ae0\u8282\u5185\u5bb9\u5df2\u66f4\u65b0\uff0c\u8bf7\u5728\u7ebf\u9605\u8bfb\u6700\u65b0RHEL 8\u7248\u672c\u4e66\u7c4d 👇<\/span><\/strong><\/span><\/p>\n

https:\/\/lrxjmw.cn\/basic-learning-11.html<\/span><\/strong><\/span><\/b><\/p>\n

\u7ae0\u8282\u7b80\u8ff0\uff1a<\/strong><\/span><\/div>\n

\u672c\u7ae0\u5f00\u7bc7\u8bb2\u89e3\u4e86\u4ec0\u4e48\u662f\u6587\u4ef6\u4f20\u8f93\u534f\u8bae\uff08File Transfer Protocol\uff0cFTP\uff09\uff0c\u4ee5\u53ca\u5982\u4f55\u90e8\u7f72vsftpd\u670d\u52a1\u7a0b\u5e8f\uff0c\u7136\u540e\u6df1\u5ea6\u5256\u6790\u4e86vsftpd\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u6700\u5e38\u7528\u7684\u53c2\u6570\u53ca\u5176\u4f5c\u7528\uff0c\u5e76\u5b8c\u6574\u6f14\u793a\u4e86vsftpd\u670d\u52a1\u7a0b\u5e8f\u4e09\u79cd\u8ba4\u8bc1\u6a21\u5f0f\uff08\u533f\u540d\u5f00\u653e\u6a21\u5f0f\u3001\u672c\u5730\u7528\u6237\u6a21\u5f0f\u3001\u865a\u62df\u7528\u6237\u6a21\u5f0f\uff09\u7684\u914d\u7f6e\u65b9\u6cd5\u3002\u672c\u7ae0\u8fd8\u6db5\u76d6\u4e86\u53ef\u63d2\u62d4\u8ba4\u8bc1\u6a21\u5757\uff08Pluggable Authentication Module\uff0cPAM\uff09\u7684\u539f\u7406\u3001\u4f5c\u7528\u4ee5\u53ca\u5b9e\u7528\u914d\u7f6e\u65b9\u6cd5\u3002<\/p>\n

\u8bfb\u8005\u5c06\u901a\u8fc7\u672c\u7ae0\u4ecb\u7ecd\u7684\u5b9e\u6218\u5185\u5bb9\u8fdb\u4e00\u6b65\u7ec3\u4e60SELinux\u670d\u52a1\u7684\u914d\u7f6e\u65b9\u6cd5\uff0c\u638c\u63e1\u7b80\u5355\u6587\u4ef6\u4f20\u8f93\u534f\u8bae\uff08Trivial File Transfer Protocol\uff0cTFTP\uff09\u7684\u7406\u8bba\u53ca\u914d\u7f6e\u65b9\u6cd5\uff0c\u4ee5\u53ca\u5b66\u4e60\u5218\u9044\u8001\u5e08\u5728\u670d\u52a1\u90e8\u7f72\u548c\u6392\u9519\u65b9\u9762\u7684\u7ecf\u9a8c\u6280\u5de7\uff0c\u4ee5\u4fbf\u7075\u6d3b\u5e94\u5bf9\u751f\u4ea7\u73af\u5883\u4e2d\u9047\u5230\u7684\u5404\u79cd\u95ee\u9898\u3002<\/p>\n

11.1 \u6587\u4ef6\u4f20\u8f93\u534f\u8bae<\/strong><\/span><\/h5>\n

\u4e00\u822c\u6765\u8bb2\uff0c\u4eba\u4eec\u5c06\u8ba1\u7b97\u673a\u8054\u7f51\u7684\u9996\u8981\u76ee\u7684\u5c31\u662f\u83b7\u53d6\u8d44\u6599\uff0c\u800c\u6587\u4ef6\u4f20\u8f93\u662f\u4e00\u79cd\u975e\u5e38\u91cd\u8981\u7684\u83b7\u53d6\u8d44\u6599\u7684\u65b9\u5f0f\u3002\u4eca\u5929\u7684\u4e92\u8054\u7f51\u662f\u7531\u51e0\u5343\u4e07\u53f0\u4e2a\u4eba\u8ba1\u7b97\u673a\u3001\u5de5\u4f5c\u7ad9\u3001\u670d\u52a1\u5668\u3001\u5c0f\u578b\u673a\u3001\u5927\u578b\u673a\u3001\u5de8\u578b\u673a\u7b49\u5177\u6709\u4e0d\u540c\u578b\u53f7\u3001\u4e0d\u540c\u67b6\u6784\u7684\u7269\u7406\u8bbe\u5907\u5171\u540c\u7ec4\u6210\u7684\uff0c\u800c\u4e14\u5373\u4fbf\u662f\u4e2a\u4eba\u8ba1\u7b97\u673a\uff0c\u4e5f\u53ef\u80fd\u4f1a\u88c5\u6709Windows\u3001Linux\u3001UNIX\u3001Mac\u7b49\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u3002\u4e3a\u4e86\u80fd\u591f\u5728\u5982\u6b64\u590d\u6742\u591a\u6837\u7684\u8bbe\u5907\u4e4b\u95f4\u89e3\u51b3\u95ee\u9898\u89e3\u51b3\u6587\u4ef6\u4f20\u8f93\u95ee\u9898\uff0c\u6587\u4ef6\u4f20\u8f93\u534f\u8bae\uff08FTP\uff09\u5e94\u8fd0\u800c\u751f\u3002<\/p>\n

FTP\u662f\u4e00\u79cd\u5728\u4e92\u8054\u7f51\u4e2d\u8fdb\u884c\u6587\u4ef6\u4f20\u8f93\u7684\u534f\u8bae\uff0c\u57fa\u4e8e\u5ba2\u6237\u7aef\/\u670d\u52a1\u5668\u6a21\u5f0f\uff0c\u9ed8\u8ba4\u4f7f\u752820\u300121\u53f7\u7aef\u53e3\uff0c\u5176\u4e2d\u7aef\u53e320\uff08\u6570\u636e\u7aef\u53e3\uff09\u7528\u4e8e\u8fdb\u884c\u6570\u636e\u4f20\u8f93\uff0c\u7aef\u53e321\uff08\u547d\u4ee4\u7aef\u53e3\uff09\u7528\u4e8e\u63a5\u53d7\u5ba2\u6237\u7aef\u53d1\u51fa\u7684\u76f8\u5173FTP\u547d\u4ee4\u4e0e\u53c2\u6570\u3002FTP\u670d\u52a1\u5668\u666e\u904d\u90e8\u7f72\u4e8e\u5185\u7f51\u4e2d\uff0c\u5177\u6709\u5bb9\u6613\u642d\u5efa\u3001\u65b9\u4fbf\u7ba1\u7406\u7684\u7279\u70b9\u3002\u800c\u4e14\u6709\u4e9bFTP\u5ba2\u6237\u7aef\u5de5\u5177\u8fd8\u53ef\u4ee5\u652f\u6301\u6587\u4ef6\u7684\u591a\u70b9\u4e0b\u8f7d\u4ee5\u53ca\u65ad\u70b9\u7eed\u4f20\u6280\u672f\uff0c\u56e0\u6b64FTP\u670d\u52a1\u5f97\u5230\u4e86\u5e7f\u5927\u7528\u6237\u7684\u9752\u7750\u3002FTP\u534f\u8bae\u7684\u4f20\u8f93\u62d3\u6251\u5982\u56fe11-1\u6240\u793a\u3002<\/p>\n

\"FTP\u8fde\u63a5\u8fc7\u7a0b\"<\/p>\n

\u56fe11-1 \u00a0FTP\u534f\u8bae\u7684\u4f20\u8f93\u62d3\u6251<\/p>\n

FTP\u670d\u52a1\u5668\u662f\u6309\u7167FTP\u534f\u8bae\u5728\u4e92\u8054\u7f51\u4e0a\u63d0\u4f9b\u6587\u4ef6\u5b58\u50a8\u548c\u8bbf\u95ee\u670d\u52a1\u7684\u4e3b\u673a\uff0cFTP\u5ba2\u6237\u7aef\u5219\u662f\u5411\u670d\u52a1\u5668\u53d1\u9001\u8fde\u63a5\u8bf7\u6c42\uff0c\u4ee5\u5efa\u7acb\u6570\u636e\u4f20\u8f93\u94fe\u8def\u7684\u4e3b\u673a\u3002FTP\u534f\u8bae\u6709\u4e0b\u9762\u4e24\u79cd\u5de5\u4f5c\u6a21\u5f0f\u3002<\/p>\n

\u4e3b\u52a8\u6a21\u5f0f<\/strong>\uff1aFTP\u670d\u52a1\u5668\u4e3b\u52a8\u5411\u5ba2\u6237\u7aef\u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42\u3002<\/p>\n

\u88ab\u52a8\u6a21\u5f0f<\/strong>\uff1aFTP\u670d\u52a1\u5668\u7b49\u5f85\u5ba2\u6237\u7aef\u53d1\u8d77\u8fde\u63a5\u8bf7\u6c42\uff08FTP\u7684\u9ed8\u8ba4\u5de5\u4f5c\u6a21\u5f0f\uff09\u3002<\/p><\/blockquote>\n

\u7b2c8\u7ae0\u5728\u5b66\u4e60\u9632\u706b\u5899\u670d\u52a1\u914d\u7f6e\u65f6\u66fe\u7ecf\u8bb2\u8fc7\uff0c\u9632\u706b\u5899\u4e00\u822c\u662f\u7528\u4e8e\u8fc7\u6ee4\u4ece\u5916\u7f51\u8fdb\u5165\u5185\u7f51\u7684\u6d41\u91cf\uff0c\u56e0\u6b64\u6709\u4e9b\u65f6\u5019\u9700\u8981\u5c06FTP\u7684\u5de5\u4f5c\u6a21\u5f0f\u8bbe\u7f6e\u4e3a\u4e3b\u52a8\u6a21\u5f0f\uff0c\u624d\u53ef\u4ee5\u4f20\u8f93\u6570\u636e\u3002<\/p>\n

vsftpd\uff08very secure ftp daemon\uff0c\u975e\u5e38\u5b89\u5168\u7684FTP\u5b88\u62a4\u8fdb\u7a0b\uff09\u662f\u4e00\u6b3e\u8fd0\u884c\u5728Linux\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u7684FTP\u670d\u52a1\u7a0b\u5e8f\uff0c\u4e0d\u4ec5\u5b8c\u5168\u5f00\u6e90\u800c\u4e14\u514d\u8d39\uff0c\u6b64\u5916\uff0c\u8fd8\u5177\u6709\u5f88\u9ad8\u7684\u5b89\u5168\u6027\u3001\u4f20\u8f93\u901f\u5ea6\uff0c\u4ee5\u53ca\u652f\u6301\u865a\u62df\u7528\u6237\u9a8c\u8bc1\u7b49\u5176\u4ed6FTP\u670d\u52a1\u7a0b\u5e8f\u4e0d\u5177\u5907\u7684\u7279\u70b9\u3002<\/p>\n

\u5728\u914d\u7f6e\u59a5\u5f53Yum\u8f6f\u4ef6\u4ed3\u5e93\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5b89\u88c5vsftpd\u670d\u52a1\u7a0b\u5e8f\u4e86\u3002<\/p>\n

[root@linuxprobe ~]# yum install vsftpd\r\nLoaded plugins: langpacks, product-id, subscription-manager\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\r\n================================================================================\r\n Package Arch Version Repository Size\r\n================================================================================\r\nInstalling:\r\n vsftpd x86_64 3.0.2-9.el7 rhel 166 k\r\nTransaction Summary\r\n================================================================================\r\nInstall 1 Package\r\nTotal download size: 166 k\r\nInstalled size: 343 k\r\nIs this ok [y\/d\/N]: y<\/strong>\r\nDownloading packages:\r\nRunning transaction check\r\nRunning transaction test\r\nTransaction test succeeded\r\nRunning transaction\r\n Installing : vsftpd-3.0.2-9.el7.x86_64 1\/1 \r\n Verifying : vsftpd-3.0.2-9.el7.x86_64 1\/1 \r\nInstalled:\r\n vsftpd.x86_64 0:3.0.2-9.el7 \r\nComplete!\r\n<\/pre>\n

iptables\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\u9ed8\u8ba4\u7981\u6b62\u4e86FTP\u4f20\u8f93\u534f\u8bae\u7684\u7aef\u53e3\u53f7\uff0c\u56e0\u6b64\u5728\u6b63\u5f0f\u914d\u7f6evsftpd\u670d\u52a1\u7a0b\u5e8f\u4e4b\u524d\uff0c\u4e3a\u4e86\u907f\u514d\u8fd9\u4e9b\u9ed8\u8ba4\u7684\u9632\u706b\u5899\u7b56\u7565\u201c\u6363\u4e71\u201d\uff0c\u8fd8\u9700\u8981\u6e05\u7a7aiptables\u9632\u706b\u5899\u7684\u9ed8\u8ba4\u7b56\u7565\uff0c\u5e76\u628a\u5f53\u524d\u5df2\u7ecf\u88ab\u6e05\u7406\u7684\u9632\u706b\u5899\u7b56\u7565\u72b6\u6001\u4fdd\u5b58\u4e0b\u6765\uff1a<\/p>\n

[root@linuxprobe ~]# iptables -F\r\n[root@linuxprobe ~]# service iptables save\r\niptables: Saving firewall rules to \/etc\/sysconfig\/iptables:[ OK ]\r\n<\/pre>\n

vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\uff08\/etc\/vsftpd\/vsftpd.conf\uff09\u5185\u5bb9\u603b\u957f\u5ea6\u8fbe\u5230123\u884c\uff0c\u4f46\u5176\u4e2d\u5927\u591a\u6570\u53c2\u6570\u5728\u5f00\u5934\u90fd\u6dfb\u52a0\u4e86\u4e95\u53f7\uff08#\uff09\uff0c\u4ece\u800c\u6210\u4e3a\u6ce8\u91ca\u4fe1\u606f\uff0c\u5927\u5bb6\u6ca1\u6709\u5fc5\u8981\u5728\u6ce8\u91ca\u4fe1\u606f\u4e0a\u82b1\u8d39\u592a\u591a\u7684\u65f6\u95f4\u3002\u6211\u4eec\u53ef\u4ee5\u5728grep\u547d\u4ee4\u540e\u9762\u6dfb\u52a0-v\u53c2\u6570\uff0c\u8fc7\u6ee4\u5e76\u53cd\u9009\u51fa\u6ca1\u6709\u5305\u542b\u4e95\u53f7\uff08#\uff09\u7684\u53c2\u6570\u884c\uff08\u5373\u8fc7\u6ee4\u6389\u6240\u6709\u7684\u6ce8\u91ca\u4fe1\u606f\uff09\uff0c\u7136\u540e\u5c06\u8fc7\u6ee4\u540e\u7684\u53c2\u6570\u884c\u901a\u8fc7\u8f93\u51fa\u91cd\u5b9a\u5411\u7b26\u5199\u56de\u539f\u59cb\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\uff1a<\/p>\n

[root@linuxprobe ~]# mv \/etc\/vsftpd\/vsftpd.conf \/etc\/vsftpd\/vsftpd.conf_bak\r\n[root@linuxprobe ~]# grep -v \"#\" \/etc\/vsftpd\/vsftpd.conf_bak > \/etc\/vsftpd\/vsftpd.conf\r\n[root@linuxprobe ~]# cat \/etc\/vsftpd\/vsftpd.conf\r\nanonymous_enable=YES\r\nlocal_enable=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\r\nuserlist_enable=YES\r\ntcp_wrappers=YES\r\n<\/pre>\n

\u886811-1\u4e2d\u7f57\u5217\u4e86vsftpd\u670d\u52a1\u7a0b\u5e8f\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u5e38\u7528\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u3002\u5f53\u524d\u5927\u5bb6\u53ea\u9700\u8981\u7b80\u5355\u4e86\u89e3\u5373\u53ef\uff0c\u5728\u540e\u7eed\u7684\u5b9e\u9a8c\u4e2d\u5c06\u6f14\u793a\u8fd9\u4e9b\u53c2\u6570\u7684\u7528\u6cd5\uff0c\u4ee5\u5e2e\u52a9\u5927\u5bb6\u719f\u6089\u5e76\u638c\u63e1\u3002<\/p>\n

\u886811-1\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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 vsftpd\u670d\u52a1\u7a0b\u5e8f\u5e38\u7528\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
listen=[YES|NO]<\/td>\n\u662f\u5426\u4ee5\u72ec\u7acb\u8fd0\u884c\u7684\u65b9\u5f0f\u76d1\u542c\u670d\u52a1<\/td>\n<\/tr>\n
listen_address=IP\u5730\u5740<\/td>\n\u8bbe\u7f6e\u8981\u76d1\u542c\u7684IP\u5730\u5740<\/td>\n<\/tr>\n
listen_port=21<\/td>\n\u8bbe\u7f6eFTP\u670d\u52a1\u7684\u76d1\u542c\u7aef\u53e3<\/td>\n<\/tr>\n
download_enable\uff1d[YES|NO]<\/td>\n\u662f\u5426\u5141\u8bb8\u4e0b\u8f7d\u6587\u4ef6<\/td>\n<\/tr>\n
userlist_enable=[YES|NO]
\nuserlist_deny=[YES|NO]<\/td>\n
\u8bbe\u7f6e\u7528\u6237\u5217\u8868\u4e3a\u201c\u5141\u8bb8\u201d\u8fd8\u662f\u201c\u7981\u6b62\u201d\u64cd\u4f5c<\/td>\n<\/tr>\n
max_clients=0<\/td>\n\u6700\u5927\u5ba2\u6237\u7aef\u8fde\u63a5\u6570\uff0c0\u4e3a\u4e0d\u9650\u5236<\/td>\n<\/tr>\n
max_per_ip=0<\/td>\n\u540c\u4e00IP\u5730\u5740\u7684\u6700\u5927\u8fde\u63a5\u6570\uff0c0\u4e3a\u4e0d\u9650\u5236<\/td>\n<\/tr>\n
anonymous_enable=[YES|NO]<\/td>\n\u662f\u5426\u5141\u8bb8\u533f\u540d\u7528\u6237\u8bbf\u95ee<\/td>\n<\/tr>\n
anon_upload_enable=[YES|NO]<\/td>\n\u662f\u5426\u5141\u8bb8\u533f\u540d\u7528\u6237\u4e0a\u4f20\u6587\u4ef6<\/td>\n<\/tr>\n
anon_umask=022<\/td>\n\u533f\u540d\u7528\u6237\u4e0a\u4f20\u6587\u4ef6\u7684umask\u503c<\/td>\n<\/tr>\n
anon_root=\/var\/ftp<\/td>\n\u533f\u540d\u7528\u6237\u7684FTP\u6839\u76ee\u5f55<\/td>\n<\/tr>\n
anon_mkdir_write_enable=[YES|NO]<\/td>\n\u662f\u5426\u5141\u8bb8\u533f\u540d\u7528\u6237\u521b\u5efa\u76ee\u5f55<\/td>\n<\/tr>\n
anon_other_write_enable=[YES|NO]<\/td>\n\u662f\u5426\u5f00\u653e\u533f\u540d\u7528\u6237\u7684\u5176\u4ed6\u5199\u5165\u6743\u9650\uff08\u5305\u62ec\u91cd\u547d\u540d\u3001\u5220\u9664\u7b49\u64cd\u4f5c\u6743\u9650\uff09<\/td>\n<\/tr>\n
anon_max_rate=0<\/td>\n\u533f\u540d\u7528\u6237\u7684\u6700\u5927\u4f20\u8f93\u901f\u7387\uff08\u5b57\u8282\/\u79d2\uff09\uff0c0\u4e3a\u4e0d\u9650\u5236<\/td>\n<\/tr>\n
local_enable=[YES|NO]<\/td>\n\u662f\u5426\u5141\u8bb8\u672c\u5730\u7528\u6237\u767b\u5f55FTP<\/td>\n<\/tr>\n
local_umask=022<\/td>\n\u672c\u5730\u7528\u6237\u4e0a\u4f20\u6587\u4ef6\u7684umask\u503c<\/td>\n<\/tr>\n
local_root=\/var\/ftp<\/td>\n\u672c\u5730\u7528\u6237\u7684FTP\u6839\u76ee\u5f55<\/td>\n<\/tr>\n
chroot_local_user=[YES|NO]<\/td>\n\u662f\u5426\u5c06\u7528\u6237\u6743\u9650\u7981\u9522\u5728FTP\u76ee\u5f55\uff0c\u4ee5\u786e\u4fdd\u5b89\u5168<\/td>\n<\/tr>\n
local_max_rate=0<\/td>\n\u672c\u5730\u7528\u6237\u6700\u5927\u4f20\u8f93\u901f\u7387\uff08\u5b57\u8282\/\u79d2\uff09\uff0c0\u4e3a\u4e0d\u9650\u5236<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

11.2 Vsftpd\u670d\u52a1\u7a0b\u5e8f<\/strong><\/span><\/h5>\n

vsftpd\u4f5c\u4e3a\u66f4\u52a0\u5b89\u5168\u7684\u6587\u4ef6\u4f20\u8f93\u7684\u670d\u52a1\u7a0b\u5e8f\uff0c\u5141\u8bb8\u7528\u6237\u4ee5\u4e09\u79cd\u8ba4\u8bc1\u6a21\u5f0f\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u4e0a\u3002<\/p>\n

\u533f\u540d\u5f00\u653e\u6a21\u5f0f<\/strong>\uff1a\u662f\u4e00\u79cd\u6700\u4e0d\u5b89\u5168\u7684\u8ba4\u8bc1\u6a21\u5f0f\uff0c\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u65e0\u9700\u5bc6\u7801\u9a8c\u8bc1\u800c\u76f4\u63a5\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u3002<\/p>\n

\u672c\u5730\u7528\u6237\u6a21\u5f0f<\/strong>\uff1a\u662f\u901a\u8fc7Linux\u7cfb\u7edf\u672c\u5730\u7684\u8d26\u6237\u5bc6\u7801\u4fe1\u606f\u8fdb\u884c\u8ba4\u8bc1\u7684\u6a21\u5f0f\uff0c\u76f8\u8f83\u4e8e\u533f\u540d\u5f00\u653e\u6a21\u5f0f\u66f4\u5b89\u5168\uff0c\u800c\u4e14\u914d\u7f6e\u8d77\u6765\u4e5f\u5f88\u7b80\u5355\u3002\u4f46\u662f\u5982\u679c\u88ab\u9ed1\u5ba2\u7834\u89e3\u4e86\u8d26\u6237\u7684\u4fe1\u606f\uff0c\u5c31\u53ef\u4ee5\u7545\u901a\u65e0\u963b\u5730\u767b\u5f55FTP\u670d\u52a1\u5668\uff0c\u4ece\u800c\u5b8c\u5168\u63a7\u5236\u6574\u53f0\u670d\u52a1\u5668\u3002<\/p>\n

\u865a\u62df\u7528\u6237\u6a21\u5f0f<\/strong>\uff1a\u662f\u8fd9\u4e09\u79cd\u6a21\u5f0f\u4e2d\u6700\u5b89\u5168\u7684\u4e00\u79cd\u8ba4\u8bc1\u6a21\u5f0f\uff0c\u5b83\u9700\u8981\u4e3aFTP\u670d\u52a1\u5355\u72ec\u5efa\u7acb\u7528\u6237\u6570\u636e\u5e93\u6587\u4ef6\uff0c\u865a\u62df\u51fa\u7528\u6765\u8fdb\u884c\u53e3\u4ee4\u9a8c\u8bc1\u7684\u8d26\u6237\u4fe1\u606f\uff0c\u800c\u8fd9\u4e9b\u8d26\u6237\u4fe1\u606f\u5728\u670d\u52a1\u5668\u7cfb\u7edf\u4e2d\u5b9e\u9645\u4e0a\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u4ec5\u4f9bFTP\u670d\u52a1\u7a0b\u5e8f\u8fdb\u884c\u8ba4\u8bc1\u4f7f\u7528\u3002\u8fd9\u6837\uff0c\u5373\u4f7f\u9ed1\u5ba2\u7834\u89e3\u4e86\u8d26\u6237\u4fe1\u606f\u4e5f\u65e0\u6cd5\u767b\u5f55\u670d\u52a1\u5668\uff0c\u4ece\u800c\u6709\u6548\u964d\u4f4e\u4e86\u7834\u574f\u8303\u56f4\u548c\u5f71\u54cd\u3002<\/p>\n

ftp\u662fLinux\u7cfb\u7edf\u4e2d\u4ee5\u547d\u4ee4\u884c\u754c\u9762\u7684\u65b9\u5f0f\u6765\u7ba1\u7406FTP\u4f20\u8f93\u670d\u52a1\u7684\u5ba2\u6237\u7aef\u5de5\u5177\u3002\u6211\u4eec\u9996\u5148\u624b\u52a8\u5b89\u88c5\u8fd9\u4e2aftp\u5ba2\u6237\u7aef\u5de5\u5177\uff0c\u4ee5\u4fbf\u5728\u540e\u7eed\u5b9e\u9a8c\u4e2d\u67e5\u770b\u7ed3\u679c\u3002<\/p>\n

[root@linuxprobe ~]# yum install ftp\r\nLoaded plugins: langpacks, product-id, subscription-manager\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\r\nInstalling:\r\n ftp x86_64 0.17-66.el7 rhel 61 k\r\nTransaction Summary\r\n================================================================================\r\nInstall 1 Package\r\nTotal download size: 61 k\r\nInstalled size: 96 k\r\nIs this ok [y\/d\/N]: y<\/strong>\r\nDownloading packages:\r\nRunning transaction check\r\nRunning transaction test\r\nTransaction test succeeded\r\nRunning transaction\r\n Installing : ftp-0.17-66.el7.x86_64 1\/1 \r\n Verifying : ftp-0.17-66.el7.x86_64 1\/1\r\nInstalled:\r\n ftp.x86_64 0:0.17-66.el7\r\nComplete!<\/pre>\n
11.2.1 \u533f\u540d\u8bbf\u95ee\u6a21\u5f0f<\/strong><\/span><\/h6>\n

\u524d\u6587\u63d0\u5230\uff0c\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u4e2d\uff0c\u533f\u540d\u5f00\u653e\u6a21\u5f0f\u662f\u6700\u4e0d\u5b89\u5168\u7684\u4e00\u79cd\u8ba4\u8bc1\u6a21\u5f0f\u3002\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u65e0\u9700\u5bc6\u7801\u9a8c\u8bc1\u800c\u76f4\u63a5\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u3002\u8fd9\u79cd\u6a21\u5f0f\u4e00\u822c\u7528\u6765\u8bbf\u95ee\u4e0d\u91cd\u8981\u7684\u516c\u5f00\u6587\u4ef6\uff08\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u5c3d\u91cf\u4e0d\u8981\u5b58\u653e\u91cd\u8981\u6587\u4ef6\uff09\u3002\u5f53\u7136\uff0c\u5982\u679c\u91c7\u7528\u7b2c8\u7ae0\u4e2d\u4ecb\u7ecd\u7684\u9632\u706b\u5899\u7ba1\u7406\u5de5\u5177\uff08\u5982Tcp_wrappers\u670d\u52a1\u7a0b\u5e8f\uff09\u5c06vsftpd\u670d\u52a1\u7a0b\u5e8f\u5141\u8bb8\u8bbf\u95ee\u7684\u4e3b\u673a\u8303\u56f4\u8bbe\u7f6e\u4e3a\u4f01\u4e1a\u5185\u7f51\uff0c\u4e5f\u53ef\u4ee5\u63d0\u4f9b\u57fa\u672c\u7684\u5b89\u5168\u6027\u3002<\/p>\n

vsftpd\u670d\u52a1\u7a0b\u5e8f\u9ed8\u8ba4\u5f00\u542f\u4e86\u533f\u540d\u5f00\u653e\u6a21\u5f0f\uff0c\u6211\u4eec\u9700\u8981\u505a\u7684\u5c31\u662f\u5f00\u653e\u533f\u540d\u7528\u6237\u7684\u4e0a\u4f20\u3001\u4e0b\u8f7d\u6587\u4ef6\u7684\u6743\u9650\uff0c\u4ee5\u53ca\u8ba9\u533f\u540d\u7528\u6237\u521b\u5efa\u3001\u5220\u9664\u3001\u66f4\u540d\u6587\u4ef6\u7684\u6743\u9650\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u9488\u5bf9\u533f\u540d\u7528\u6237\u653e\u5f00\u8fd9\u4e9b\u6743\u9650\u4f1a\u5e26\u6765\u6f5c\u5728\u5371\u9669\uff0c\u6211\u4eec\u53ea\u662f\u4e3a\u4e86\u5728Linux\u7cfb\u7edf\u4e2d\u7ec3\u4e60\u914d\u7f6evsftpd\u670d\u52a1\u7a0b\u5e8f\u800c\u653e\u5f00\u4e86\u8fd9\u4e9b\u6743\u9650\uff0c\u4e0d\u5efa\u8bae\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u5982\u6b64\u884c\u4e8b\u3002\u886811-2\u7f57\u5217\u4e86\u53ef\u4ee5\u5411\u533f\u540d\u7528\u6237\u5f00\u653e\u7684\u6743\u9650\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u3002<\/p>\n

\u886811-2\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\u00a0\u00a0\u00a0\u00a0\u00a0 \u53ef\u4ee5\u5411\u533f\u540d\u7528\u6237\u5f00\u653e\u7684\u6743\u9650\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
anonymous_enable=YES<\/td>\n\u5141\u8bb8\u533f\u540d\u8bbf\u95ee\u6a21\u5f0f<\/td>\n<\/tr>\n
anon_umask=022<\/td>\n\u533f\u540d\u7528\u6237\u4e0a\u4f20\u6587\u4ef6\u7684umask\u503c<\/td>\n<\/tr>\n
anon_upload_enable=YES<\/td>\n\u5141\u8bb8\u533f\u540d\u7528\u6237\u4e0a\u4f20\u6587\u4ef6<\/td>\n<\/tr>\n
anon_mkdir_write_enable=YES<\/td>\n\u5141\u8bb8\u533f\u540d\u7528\u6237\u521b\u5efa\u76ee\u5f55<\/td>\n<\/tr>\n
anon_other_write_enable=YES<\/td>\n\u5141\u8bb8\u533f\u540d\u7528\u6237\u4fee\u6539\u76ee\u5f55\u540d\u79f0\u6216\u5220\u9664\u76ee\u5f55<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

[root@linuxprobe ~]# vim \/etc\/vsftpd\/vsftpd.conf\r\n1 anonymous_enable=YES<\/strong>\r\n2 anon_umask=022<\/strong>\r\n3 anon_upload_enable=YES<\/strong>\r\n4 anon_mkdir_write_enable=YES<\/strong>\r\n5 anon_other_write_enable=YES<\/strong>\r\n6 local_enable=YES\r\n7 write_enable=YES\r\n8 local_umask=022\r\n9 dirmessage_enable=YES\r\n10 xferlog_enable=YES\r\n11 connect_from_port_20=YES\r\n12 xferlog_std_format=YES\r\n13 listen=NO\r\n14 listen_ipv6=YES\r\n15 pam_service_name=vsftpd\r\n16 userlist_enable=YES\r\n17 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\u6b64\u9700\u8981\u63d0\u9192\u5404\u4f4d\u8bfb\u8005\uff0c\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u6216\u8005\u5728RHCSA\u3001RHCE<\/a>\u3001RHCA<\/a>\u8ba4\u8bc1\u8003\u8bd5\u4e2d\u4e00\u5b9a\u8981\u628a\u914d\u7f6e\u8fc7\u7684\u670d\u52a1\u7a0b\u5e8f\u52a0\u5165\u5230\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff0c\u4ee5\u4fdd\u8bc1\u670d\u52a1\u5668\u5728\u91cd\u542f\u540e\u4f9d\u7136\u80fd\u591f\u6b63\u5e38\u63d0\u4f9b\u4f20\u8f93\u670d\u52a1\uff1a<\/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

\u73b0\u5728\u5c31\u53ef\u4ee5\u5728\u5ba2\u6237\u7aef\u6267\u884cftp\u547d\u4ee4\u8fde\u63a5\u5230\u8fdc\u7a0b\u7684FTP\u670d\u52a1\u5668\u4e86\u3002\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u533f\u540d\u5f00\u653e\u8ba4\u8bc1\u6a21\u5f0f\u4e0b\uff0c\u5176\u8d26\u6237\u7edf\u4e00\u4e3aanonymous\uff0c\u5bc6\u7801\u4e3a\u7a7a\u3002\u800c\u4e14\u5728\u8fde\u63a5\u5230FTP\u670d\u52a1\u5668\u540e\uff0c\u9ed8\u8ba4\u8bbf\u95ee\u7684\u662f\/var\/ftp\u76ee\u5f55\u3002\u6211\u4eec\u53ef\u4ee5\u5207\u6362\u5230\u8be5\u76ee\u5f55\u4e0b\u7684pub\u76ee\u5f55\u4e2d\uff0c\u7136\u540e\u5c1d\u8bd5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\u6587\u4ef6\uff0c\u4ee5\u68c0\u9a8c\u662f\u5426\u62e5\u6709\u5199\u5165\u6743\u9650\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): anonymous<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u6572\u51fb\u56de\u8f66\u5373\u53ef<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> cd pub\r\n250 Directory successfully changed.\r\nftp> mkdir files\r\n550 Permission denied.<\/pre>\n

\u7cfb\u7edf\u663e\u793a\u62d2\u7edd\u521b\u5efa\u76ee\u5f55\uff01\u6211\u4eec\u660e\u660e\u5728\u524d\u9762\u6e05\u7a7a\u4e86iptables\u9632\u706b\u5899\u7b56\u7565\uff0c\u800c\u4e14\u4e5f\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u4e3b\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e86\u5141\u8bb8\u533f\u540d\u7528\u6237\u521b\u5efa\u76ee\u5f55\u548c\u5199\u5165\u6587\u4ef6\u7684\u6743\u9650\u554a\u3002\u5efa\u8bae\u5927\u5bb6\u5148\u4e0d\u8981\u7740\u6025\u5f80\u4e0b\u770b\uff0c\u800c\u662f\u81ea\u5df1\u601d\u8003\u4e00\u4e0b\u8fd9\u4e2a\u95ee\u9898\u7684\u89e3\u51b3\u529e\u6cd5\uff0c\u4ee5\u953b\u70bc\u60a8\u7684Linux\u7cfb\u7edf\u6392\u9519\u80fd\u529b\u3002<\/p>\n

\u524d\u6587\u63d0\u5230\uff0c\u5728vsftpd\u670d\u52a1\u7a0b\u5e8f\u7684\u533f\u540d\u5f00\u653e\u8ba4\u8bc1\u6a21\u5f0f\u4e0b\uff0c\u9ed8\u8ba4\u8bbf\u95ee\u7684\u662f\/var\/ftp\u76ee\u5f55\u3002\u67e5\u770b\u8be5\u76ee\u5f55\u7684\u6743\u9650\u5f97\u77e5\uff0c\u53ea\u6709root\u7ba1\u7406\u5458\u624d\u6709\u5199\u5165\u6743\u9650\u3002\u602a\u4e0d\u5f97\u7cfb\u7edf\u4f1a\u62d2\u7edd\u64cd\u4f5c\u5462\uff01\u4e0b\u9762\u5c06\u76ee\u5f55\u7684\u6240\u6709\u8005\u8eab\u4efd\u6539\u6210\u7cfb\u7edf\u8d26\u6237ftp\u5373\u53ef\uff08\u8be5\u8d26\u6237\u5728\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b58\u5728\uff09\uff0c\u8fd9\u6837\u5e94\u8be5\u53ef\u4ee5\u4e86\u5427\uff1a<\/p>\n

[root@linuxprobe ~]# ls -ld \/var\/ftp\/pub\r\ndrwxr-xr-x. 3 root root 16 Jul 13 14:38 \/var\/ftp\/pub\r\n[root@linuxprobe ~]# chown -Rf ftp \/var\/ftp\/pub\r\n[root@linuxprobe ~]# ls -ld \/var\/ftp\/pub\r\ndrwxr-xr-x. 3 ftp root 16 Jul 13 14:38 \/var\/ftp\/pub\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): anonymous<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u6572\u51fb\u56de\u8f66\u5373\u53ef<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> cd pub\r\n250 Directory successfully changed.\r\nftp> mkdir files\r\n550 Create directory operation failed.<\/pre>\n

\u7cfb\u7edf\u518d\u6b21\u62a5\u9519\uff01\u5c3d\u7ba1\u6211\u4eec\u5728\u4f7f\u7528ftp\u547d\u4ee4\u767b\u5165FTP\u670d\u52a1\u5668\u540e\uff0c\u518d\u521b\u5efa\u76ee\u5f55\u65f6\u7cfb\u7edf\u4f9d\u7136\u63d0\u793a\u64cd\u4f5c\u5931\u8d25\uff0c\u4f46\u662f\u62a5\u9519\u4fe1\u606f\u5374\u53d1\u751f\u4e86\u53d8\u5316\u3002\u5728\u6ca1\u6709\u5199\u5165\u6743\u9650\u65f6\uff0c\u7cfb\u7edf\u63d0\u793a\u201c\u6743\u9650\u62d2\u7edd\u201d\uff08Permission denied\uff09\u6240\u4ee5\u5218\u9044\u8001\u5e08\u6000\u7591\u662f\u6743\u9650\u7684\u95ee\u9898\u3002\u4f46\u73b0\u5728\u7cfb\u7edf\u63d0\u793a\u201c\u521b\u5efa\u76ee\u5f55\u7684\u64cd\u4f5c\u5931\u8d25\u201d\uff08Create directory operation failed\uff09\uff0c\u60f3\u5fc5\u5404\u4f4d\u8bfb\u8005\u4e5f\u5e94\u8be5\u610f\u8bc6\u5230\u662fSELinux\u670d\u52a1\u5728\u201c\u6363\u4e71\u201d\u4e86\u5427\u3002<\/p>\n

\u4e0b\u9762\u4f7f\u7528getsebool\u547d\u4ee4\u67e5\u770b\u4e0eFTP\u76f8\u5173\u7684SELinux\u57df\u7b56\u7565\u90fd\u6709\u54ea\u4e9b\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<\/pre>\n

\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u7ecf\u9a8c\uff08\u9700\u8981\u957f\u671f\u57f9\u517b\uff0c\u522b\u65e0\u5b83\u6cd5\uff09\u548c\u7b56\u7565\u7684\u540d\u79f0\u5224\u65ad\u51fa\u662fftpd_full_access--> off\u7b56\u7565\u89c4\u5219\u5bfc\u81f4\u4e86\u64cd\u4f5c\u5931\u8d25\u3002\u63a5\u4e0b\u6765\u4fee\u6539\u8be5\u7b56\u7565\u89c4\u5219\uff0c\u5e76\u4e14\u5728\u8bbe\u7f6e\u65f6\u4f7f\u7528-P\u53c2\u6570\u8ba9\u4fee\u6539\u8fc7\u7684\u7b56\u7565\u6c38\u4e45\u751f\u6548\uff0c\u786e\u4fdd\u5728\u670d\u52a1\u5668\u91cd\u542f\u540e\u4f9d\u7136\u80fd\u591f\u987a\u5229\u5199\u5165\u6587\u4ef6\u3002<\/p>\n

[root@linuxprobe ~]# setsebool -P ftpd_full_access=on<\/pre>\n

\u518d\u6b21\u63d0\u9192\u5404\u4f4d\u8bfb\u8005\uff0c\u5728\u8fdb\u884c\u4e0b\u4e00\u6b21\u5b9e\u9a8c\u4e4b\u524d\uff0c\u4e00\u5b9a\u8bb0\u5f97\u5c06\u865a\u62df\u673a\u8fd8\u539f\u5230\u6700\u521d\u59cb\u7684\u72b6\u6001\uff0c\u4ee5\u514d\u591a\u4e2a\u5b9e\u9a8c\u76f8\u4e92\u4ea7\u751f\u51b2\u7a81\u3002<\/p><\/blockquote>\n

\u73b0\u5728\u4fbf\u53ef\u4ee5\u987a\u5229\u6267\u884c\u6587\u4ef6\u521b\u5efa\u3001\u4fee\u6539\u53ca\u5220\u9664\u7b49\u64cd\u4f5c\u4e86\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): anonymous<\/strong>\r\n331 Please specify the password.\r\nPassword:\u6b64\u5904\u6572\u51fb\u56de\u8f66\u5373\u53ef<\/strong>\r\n230 Login successful.\r\nRemote system type is UNIX.\r\nUsing binary mode to transfer files.\r\nftp> cd pub\r\n250 Directory successfully changed.\r\nftp> mkdir files\r\n257 \"\/pub\/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
11.2.2 \u672c\u5730\u7528\u6237\u6a21\u5f0f<\/strong><\/span><\/h6>\n

\u76f8\u8f83\u4e8e\u533f\u540d\u5f00\u653e\u6a21\u5f0f\uff0c\u672c\u5730\u7528\u6237\u6a21\u5f0f\u8981\u66f4\u5b89\u5168\uff0c\u800c\u4e14\u914d\u7f6e\u8d77\u6765\u4e5f\u5f88\u7b80\u5355\u3002\u5982\u679c\u5927\u5bb6\u4e4b\u524d\u7528\u7684\u662f\u533f\u540d\u5f00\u653e\u6a21\u5f0f\uff0c\u73b0\u5728\u5c31\u53ef\u4ee5\u5c06\u5b83\u5173\u4e86\uff0c\u7136\u540e\u5f00\u542f\u672c\u5730\u7528\u6237\u6a21\u5f0f\u3002\u9488\u5bf9\u672c\u5730\u7528\u6237\u6a21\u5f0f\u7684\u6743\u9650\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528\u5982\u886811-3\u6240\u793a\u3002<\/p>\n

\u886811-3\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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u672c\u5730\u7528\u6237\u6a21\u5f0f\u4f7f\u7528\u7684\u6743\u9650\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
anonymous_enable=NO<\/td>\n\u7981\u6b62\u533f\u540d\u8bbf\u95ee\u6a21\u5f0f<\/td>\n<\/tr>\n
local_enable=YES<\/td>\n\u5141\u8bb8\u672c\u5730\u7528\u6237\u6a21\u5f0f<\/td>\n<\/tr>\n
write_enable=YES<\/td>\n\u8bbe\u7f6e\u53ef\u5199\u6743\u9650<\/td>\n<\/tr>\n
local_umask=022<\/td>\n\u672c\u5730\u7528\u6237\u6a21\u5f0f\u521b\u5efa\u6587\u4ef6\u7684umask\u503c<\/td>\n<\/tr>\n
userlist_deny=YES<\/td>\n\u542f\u7528\u201c\u7981\u6b62\u7528\u6237\u540d\u5355\u201d\uff0c\u540d\u5355\u6587\u4ef6\u4e3aftpusers\u548cuser_list<\/td>\n<\/tr>\n
userlist_enable=YES<\/td>\n\u5f00\u542f\u7528\u6237\u4f5c\u7528\u540d\u5355\u6587\u4ef6\u529f\u80fd<\/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 write_enable=YES<\/strong>\r\n4 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>\n

11.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>\n

PAM\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

\"PAM\u8ba4\u8bc1\u673a\u5236\u7684\u4f53\u7cfb\u56fe\"<\/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\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
anonymous_enable=NO<\/td>\n\u7981\u6b62\u533f\u540d\u5f00\u653e\u6a21\u5f0f<\/td>\n<\/tr>\n
local_enable=YES<\/td>\n\u5141\u8bb8\u672c\u5730\u7528\u6237\u6a21\u5f0f<\/td>\n<\/tr>\n
guest_enable=YES<\/td>\n\u5f00\u542f\u865a\u62df\u7528\u6237\u6a21\u5f0f<\/td>\n<\/tr>\n
guest_username=virtual<\/td>\n\u6307\u5b9a\u865a\u62df\u7528\u6237\u8d26\u6237<\/td>\n<\/tr>\n
pam_service_name=vsftpd.vu<\/td>\n\u6307\u5b9aPAM\u6587\u4ef6<\/td>\n<\/tr>\n
allow_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
11.3 TFTP\u7b80\u5355\u6587\u4ef6\u4f20\u8f93\u534f\u8bae<\/strong><\/span><\/h5>\n

\u7b80\u5355\u6587\u4ef6\u4f20\u8f93\u534f\u8bae\uff08Trivial File Transfer Protocol\uff0cTFTP\uff09\u662f\u4e00\u79cd\u57fa\u4e8eUDP\u534f\u8bae\u5728\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u8fdb\u884c\u7b80\u5355\u6587\u4ef6\u4f20\u8f93\u7684\u534f\u8bae\u3002\u987e\u540d\u601d\u4e49\uff0c\u5b83\u63d0\u4f9b\u4e0d\u590d\u6742\u3001\u5f00\u9500\u4e0d\u5927\u7684\u6587\u4ef6\u4f20\u8f93\u670d\u52a1\uff08\u53ef\u5c06\u5176\u5f53\u4f5cFTP\u534f\u8bae\u7684\u7b80\u5316\u7248\u672c\uff09\u3002<\/p>\n

TFTP\u7684\u547d\u4ee4\u529f\u80fd\u4e0d\u5982FTP\u670d\u52a1\u5f3a\u5927\uff0c\u751a\u81f3\u4e0d\u80fd\u904d\u5386\u76ee\u5f55\uff0c\u5728\u5b89\u5168\u6027\u65b9\u9762\u4e5f\u5f31\u4e8eFTP\u670d\u52a1\u3002\u800c\u4e14\uff0c\u7531\u4e8eTFTP\u5728\u4f20\u8f93\u6587\u4ef6\u65f6\u91c7\u7528\u7684\u662fUDP\u534f\u8bae\uff0c\u5360\u7528\u7684\u7aef\u53e3\u53f7\u4e3a69\uff0c\u56e0\u6b64\u6587\u4ef6\u7684\u4f20\u8f93\u8fc7\u7a0b\u4e5f\u4e0d\u50cfFTP\u534f\u8bae\u90a3\u6837\u53ef\u9760\u3002\u4f46\u662f\uff0c\u56e0\u4e3aTFTP\u4e0d\u9700\u8981\u5ba2\u6237\u7aef\u7684\u6743\u9650\u8ba4\u8bc1\uff0c\u4e5f\u5c31\u51cf\u5c11\u4e86\u65e0\u8c13\u7684\u7cfb\u7edf\u548c\u7f51\u7edc\u5e26\u5bbd\u6d88\u8017\uff0c\u56e0\u6b64\u5728\u4f20\u8f93\u7410\u788e\uff08trivial\uff09\u4e0d\u5927\u7684\u6587\u4ef6\u65f6\uff0c\u6548\u7387\u66f4\u9ad8\u3002<\/p>\n

\u63a5\u4e0b\u6765\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5TFTP\u7684\u8f6f\u4ef6\u5305\uff0c\u8fdb\u884c\u4f53\u9a8c\u3002<\/p>\n

[root@linuxprobe ~]# yum install tftp-server tftp\r\nLoaded plugins: langpacks, product-id, subscription-manager\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\r\nInstalling:\r\n tftp x86_64 5.2-11.el7 rhel 35 k\r\n tftp-server x86_64 5.2-11.el7 rhel 44 k\r\nInstalling for dependencies:\r\n xinetd x86_64 2:2.3.15-12.el7 rhel 128 k\r\nTransaction Summary\r\n================================================================================\r\nInstall 2 Packages (+1 Dependent package)\r\nTotal download size: 207 k\r\nInstalled size: 373 k\r\nIs this ok [y\/d\/N]: y<\/strong>\r\nDownloading packages:\r\n\u2026\u2026\u2026\u2026\u2026\u2026\u7701\u7565\u90e8\u5206\u8f93\u51fa\u4fe1\u606f\u2026\u2026\u2026\u2026\u2026\u2026\r\nInstalled:\r\n tftp.x86_64 0:5.2-11.el7 tftp-server.x86_64 0:5.2-11.el7 \r\nDependency Installed:\r\n xinetd.x86_64 2:2.3.15-12.el7 \r\nComplete!<\/pre>\n

\u5728RHEL 7\u7cfb\u7edf\u4e2d\uff0cTFTP\u670d\u52a1\u662f\u4f7f\u7528xinetd\u670d\u52a1\u7a0b\u5e8f\u6765\u7ba1\u7406\u7684\u3002xinetd\u670d\u52a1\u53ef\u4ee5\u7528\u6765\u7ba1\u7406\u591a\u79cd\u8f7b\u91cf\u7ea7\u7684\u7f51\u7edc\u670d\u52a1\uff0c\u800c\u4e14\u5177\u6709\u5f3a\u5927\u7684\u65e5\u5fd7\u529f\u80fd\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5728\u5b89\u88c5TFTP\u8f6f\u4ef6\u5305\u540e\uff0c\u8fd8\u9700\u8981\u5728xinetd\u670d\u52a1\u7a0b\u5e8f\u4e2d\u5c06\u5176\u5f00\u542f\uff0c\u628a\u9ed8\u8ba4\u7684\u7981\u7528\uff08disable\uff09\u53c2\u6570\u4fee\u6539\u4e3ano\uff1a<\/p>\n

[root@linuxprobe ~]# vim \/etc\/xinetd.d\/tftp\r\nservice tftp\r\n{\r\n        socket_type             = dgram\r\n        protocol                = udp\r\n        wait                    = yes\r\n        user                    = root\r\n        server                  = \/usr\/sbin\/in.tftpd\r\n        server_args             = -s \/var\/lib\/tftpboot\r\n        disable                 = no<\/strong>\r\n        per_source              = 11\r\n        cps                     = 100 2\r\n        flags                   = IPv4\r\n}<\/pre>\n

\u7136\u540e\uff0c\u91cd\u542fxinetd\u670d\u52a1\u5e76\u5c06\u5b83\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u5f00\u673a\u542f\u52a8\u9879\u4e2d\uff0c\u4ee5\u786e\u4fddTFTP\u670d\u52a1\u5728\u7cfb\u7edf\u91cd\u542f\u540e\u4f9d\u7136\u5904\u4e8e\u8fd0\u884c\u72b6\u6001\u3002\u8003\u8651\u5230\u6709\u4e9b\u7cfb\u7edf\u7684\u9632\u706b\u5899\u9ed8\u8ba4\u6ca1\u6709\u5141\u8bb8UDP\u534f\u8bae\u768469\u7aef\u53e3\uff0c\u56e0\u6b64\u9700\u8981\u624b\u52a8\u5c06\u8be5\u7aef\u53e3\u53f7\u52a0\u5165\u5230\u9632\u706b\u5899\u7684\u5141\u8bb8\u7b56\u7565\u4e2d\uff1a<\/p>\n

[root@linuxprobe ~]# systemctl restart xinetd\r\n[root@linuxprobe ~]# systemctl enable xinetd\r\n[root@linuxprobe ~]# firewall-cmd --permanent --add-port=69\/udp\r\nsuccess\r\n[root@linuxprobe ~]# firewall-cmd --reload \r\nsuccess<\/pre>\n

TFTP\u7684\u6839\u76ee\u5f55\u4e3a\/var\/lib\/tftpboot\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u521a\u5b89\u88c5\u597d\u7684tftp\u547d\u4ee4\u5c1d\u8bd5\u8bbf\u95ee\u5176\u4e2d\u7684\u6587\u4ef6\uff0c\u4eb2\u8eab\u4f53\u9a8cTFTP\u670d\u52a1\u7684\u6587\u4ef6\u4f20\u8f93\u8fc7\u7a0b\u3002\u5728\u4f7f\u7528tftp\u547d\u4ee4\u8bbf\u95ee\u6587\u4ef6\u65f6\uff0c\u53ef\u80fd\u4f1a\u7528\u5230\u886811-5\u4e2d\u7684\u53c2\u6570\u3002<\/p>\n

\u886811-5\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\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tftp\u547d\u4ee4\u4e2d\u53ef\u7528\u7684\u53c2\u6570\u4ee5\u53ca\u4f5c\u7528<\/p>\n\n\n\n\n\n\n\n\n\n\n\n\n
\u53c2\u6570<\/td>\n\u4f5c\u7528<\/td>\n<\/tr>\n
?<\/td>\n\u5e2e\u52a9\u4fe1\u606f<\/td>\n<\/tr>\n
put<\/td>\n\u4e0a\u4f20\u6587\u4ef6<\/td>\n<\/tr>\n
get<\/td>\n\u4e0b\u8f7d\u6587\u4ef6<\/td>\n<\/tr>\n
verbose<\/td>\n\u663e\u793a\u8be6\u7ec6\u7684\u5904\u7406\u4fe1\u606f<\/td>\n<\/tr>\n
status<\/td>\n\u663e\u793a\u5f53\u524d\u7684\u72b6\u6001\u4fe1\u606f<\/td>\n<\/tr>\n
binary<\/td>\n\u4f7f\u7528\u4e8c\u8fdb\u5236\u8fdb\u884c\u4f20\u8f93<\/td>\n<\/tr>\n
ascii<\/td>\n\u4f7f\u7528ASCII\u7801\u8fdb\u884c\u4f20\u8f93<\/td>\n<\/tr>\n
timeout<\/td>\n\u8bbe\u7f6e\u91cd\u4f20\u7684\u8d85\u65f6\u65f6\u95f4<\/td>\n<\/tr>\n
quit<\/td>\n\u9000\u51fa<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

[root@linuxprobe\u00a0~]# echo \"i love linux\" > \/var\/lib\/tftpboot\/readme.txt\r\n[root@linuxprobe\u00a0~]# tftp 192.168.10.10\r\ntftp> get readme.txt\r\ntftp> quit\r\n[root@linuxprobe ~]# ls\r\nanaconda-ks.cfg Documents initial-setup-ks.cfg Pictures readme.txt Videos\r\nDesktop Downloads Music Public Templates\r\n[root@linuxprobe\u00a0~]# cat readme.txt \r\ni love linux<\/pre>\n

\u5f53\u7136\uff0cTFTP\u670d\u52a1\u7684\u73a9\u6cd5\u8fd8\u4e0d\u6b62\u4e8e\u6b64\uff0c\u7b2c19\u7ae0\u4f1a\u5c06TFTP\u670d\u52a1\u4e0e\u5176\u4ed6\u8f6f\u4ef6\u76f8\u642d\u914d\uff0c\u7ec4\u5408\u51fa\u4e00\u5957\u5b8c\u6574\u7684\u81ea\u52a8\u5316\u90e8\u7f72\u7cfb\u7edf\u65b9\u6848\u3002\u5927\u5bb6\u7ee7\u7eed\u52a0\u6cb9\uff01<\/p>\n

\u51fa\u73b0\u95ee\u9898?\u5927\u80c6\u63d0\u95ee!<\/strong><\/span><\/p>\n

\u56e0\u8bfb\u8005\u4eec\u786c\u4ef6\u4e0d\u540c\u6216\u64cd\u4f5c\u9519\u8bef\u90fd\u53ef\u80fd\u5bfc\u81f4\u5b9e\u9a8c\u914d\u7f6e\u51fa\u9519\uff0c\u8bf7\u8010\u5fc3\u518d\u4ed4\u7ec6\u770b\u770b\u64cd\u4f5c\u6b65\u9aa4\u5427\uff0c\u4e0d\u8981\u6c14\u9981~<\/p>\n

Linux\u6280\u672f\u4ea4\u6d41\u8bf7\u52a0A\u7fa4\uff1a560843(\u6ee1<\/span><\/strong>)\uff0cB\u7fa4\uff1a340829(\u63a8\u8350<\/span><\/strong>)\uff0cC\u7fa4\uff1a463590\uff08\u63a8\u8350<\/span><\/strong>\uff09\uff0c\u70b9\u6b64\u67e5\u770b\u5168\u56fd\u7fa4<\/a>\u3002<\/p>\n

*\u672c\u7fa4\u7279\u8272\uff1a\u901a\u8fc7\u53e3\u4ee4\u9a8c\u8bc1\u786e\u4fdd\u6bcf\u4e00\u4e2a\u7fa4\u5458\u90fd\u662f\u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b\u7684\u8bfb\u8005\uff0c\u7b54\u7591\u66f4\u6709\u9488\u5bf9\u6027\uff0c\u4e0d\u5b9a\u671f\u514d\u8d39\u9886\u53d6\u5b9a\u5236\u793c\u54c1\u3002<\/p><\/blockquote>\n

\u672c\u7ae0\u8282\u7684\u590d\u4e60\u4f5c\u4e1a<\/span>(\u7b54\u6848\u5c31\u5728\u95ee\u9898\u7684\u4e0b\u4e00\u884c\u54e6\uff0c\u7528\u9f20\u6807\u9009\u4e2d\u5373\u53ef\u770b\u5230\u7684~)<\/strong><\/span><\/p>\n

1\uff0e\u7b80\u8ff0FTP\u534f\u8bae\u7684\u529f\u80fd\u4f5c\u7528\u4ee5\u53ca\u6240\u5360\u7528\u7684\u7aef\u53e3\u53f7\u3002<\/p>\n

\u7b54\uff1a<\/strong>FTP\u662f\u4e00\u79cd\u5728\u4e92\u8054\u7f51\u4e2d\u8fdb\u884c\u6587\u4ef6\u4f20\u8f93\u7684\u534f\u8bae\uff0c\u9ed8\u8ba4\u4f7f\u752820\u300121\u53f7\u7aef\u53e3\uff0c\u5176\u4e2d\u7aef\u53e320\uff08\u6570\u636e\u7aef\u53e3\uff09\u7528\u4e8e\u8fdb\u884c\u6570\u636e\u4f20\u8f93\uff0c\u7aef\u53e321\uff08\u547d\u4ee4\u7aef\u53e3\uff09\u7528\u4e8e\u63a5\u53d7\u5ba2\u6237\u7aef\u53d1\u8d77\u7684\u76f8\u5173FTP\u547d\u4ee4\u4e0e\u53c2\u6570\u3002<\/span><\/p>\n

2\uff0evsftpd\u670d\u52a1\u7a0b\u5e8f\u63d0\u4f9b\u7684\u4e09\u79cd\u7528\u6237\u8ba4\u8bc1\u6a21\u5f0f\u5404\u81ea\u6709\u4ec0\u4e48\u7279\u70b9\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u533f\u540d\u5f00\u653e\u6a21\u5f0f\u662f\u4efb\u4f55\u4eba\u90fd\u53ef\u4ee5\u65e0\u9700\u5bc6\u7801\u8ba4\u8bc1\u5373\u53ef\u76f4\u63a5\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u7684\u9a8c\u8bc1\u65b9\u5f0f\uff1b\u672c\u5730\u7528\u6237\u6a21\u5f0f\u662f\u901a\u8fc7\u7cfb\u7edf\u672c\u5730\u7684\u8d26\u6237\u5bc6\u7801\u4fe1\u606f\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u7684\u8ba4\u8bc1\u65b9\u5f0f\uff1b\u865a\u62df\u7528\u6237\u6a21\u5f0f\u662f\u901a\u8fc7\u521b\u5efa\u72ec\u7acb\u7684FTP\u7528\u6237\u6570\u636e\u5e93\u6587\u4ef6\u6765\u8fdb\u884c\u8ba4\u8bc1\u5e76\u767b\u5f55\u5230FTP\u670d\u52a1\u5668\u7684\u8ba4\u8bc1\u65b9\u5f0f\uff0c\u76f8\u8f83\u6765\u8bf4\u5b83\u4e5f\u662f\u6700\u5b89\u5168\u7684\u8ba4\u8bc1\u6a21\u5f0f\u3002<\/span><\/p>\n

3\uff0e\u00a0\u4f7f\u7528\u533f\u540d\u5f00\u653e\u6a21\u5f0f\u767b\u5f55\u5230\u4e00\u53f0\u7528vsftpd\u670d\u52a1\u7a0b\u5e8f\u90e8\u7f72\u7684FTP\u670d\u52a1\u5668\u4e0a\u65f6\uff0c\u9ed8\u8ba4\u7684FTP\u6839\u76ee\u5f55\u662f\u4ec0\u4e48\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u4f7f\u7528\u533f\u540d\u5f00\u653e\u6a21\u5f0f\u767b\u5f55\u540e\u7684FTP\u6839\u76ee\u5f55\u662f\/var\/ftp\u76ee\u5f55\uff0c\u8be5\u76ee\u5f55\u5185\u9ed8\u8ba4\u8fd8\u4f1a\u6709\u4e00\u4e2a\u540d\u4e3apub\u7684\u5b50\u76ee\u5f55\u3002<\/span><\/p>\n

4\uff0e\u7b80\u8ff0PAM\u7684\u529f\u80fd\u4f5c\u7528\u3002<\/p>\n

\u7b54\uff1a<\/strong>PAM\u662f\u4e00\u7ec4\u5b89\u5168\u673a\u5236\u7684\u6a21\u5757\uff08\u63d2\u4ef6\uff09\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\u8fc7\u591a\u4fee\u6539\u3002<\/span><\/p>\n

5\uff0e\u4f7f\u7528\u865a\u62df\u7528\u6237\u6a21\u5f0f\u767b\u5f55FTP\u670d\u52a1\u5668\u7684\u6240\u6709\u7528\u6237\u7684\u6743\u9650\u90fd\u662f\u4e00\u6837\u7684\u5417\uff1f<\/p>\n

\u7b54\uff1a<\/strong>\u4e0d\u4e00\u5b9a\uff0c\u53ef\u4ee5\u901a\u8fc7\u5206\u522b\u5b9a\u4e49\u7528\u6237\u6743\u9650\u6587\u4ef6\u6765\u4e3a\u6bcf\u4e00\u4f4d\u7528\u6237\u8bbe\u7f6e\u4e0d\u540c\u7684\u6743\u9650\u3002<\/span><\/p>\n

6\uff0eTFTP\u534f\u8bae\u4e0eFTP\u534f\u8bae\u6709\u4ec0\u4e48\u4e0d\u540c\uff1f<\/p>\n

\u7b54\uff1a<\/strong>TFTP\u534f\u8bae\u63d0\u4f9b\u4e0d\u590d\u6742\u3001\u5f00\u9500\u4e0d\u5927\u7684\u6587\u4ef6\u4f20\u8f93\u670d\u52a1\uff08\u53ef\u5c06\u5176\u5f53\u4f5cFTP\u534f\u8bae\u7684\u7b80\u5316\u7248\u672c\uff09\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"

\u7ea2\u5e3d\u67b6\u6784\u5e08\u4e3a\u60a8\u4ecb\u7ecdFTP\u4f20\u8f93\u534f\u8bae\u7684\u4f5c\u7528\uff0c\u5b89\u88c5vsftpd\u670d\u52a1\u7a0b\u5e8f\u5e76\u9010\u6761\u5206\u6790\u670d\u52a1\u6587\u4ef6\u7684\u914d\u7f6e\u53c2\u6570\uff0c\u5b8c\u6574\u6f14\u793avsftpd\u670d\u52a1\u533f\u540d\u8bbf\u95ee\u6a21\u5f0f\u3001\u672c\u5730\u7528\u6237\u6a21\u5f0f\u53ca\u865a\u62df\u7528\u6237\u6a21\u5f0f\u7684\u914d\u7f6e\u65b9\u6cd5\u3002<\/p>\n","protected":false},"author":1,"featured_media":17176,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[558],"tags":[],"class_list":["post-1443","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rhel7"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/1443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=1443"}],"version-history":[{"count":107,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/1443\/revisions"}],"predecessor-version":[{"id":218019,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/1443\/revisions\/218019"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/17176"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=1443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=1443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=1443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}