{"id":39,"date":"2019-07-27T11:48:00","date_gmt":"2019-07-27T11:48:00","guid":{"rendered":"http:\/\/pro369.com\/linux\/?p=39"},"modified":"2019-07-27T11:48:00","modified_gmt":"2019-07-27T11:48:00","slug":"ftp%e6%aa%94%e6%a1%88%e5%82%b3%e8%bc%b8%e6%9c%8d%e5%8b%99%ef%bc%88linux%e4%b8%bb%e6%a9%9f%e4%bc%ba%e6%9c%8d%e5%99%a8%e6%9e%b6%e8%a8%ad%e6%8a%80%e8%a1%93%ef%bc%89","status":"publish","type":"post","link":"https:\/\/por.tw\/linux\/ftp%e6%aa%94%e6%a1%88%e5%82%b3%e8%bc%b8%e6%9c%8d%e5%8b%99%ef%bc%88linux%e4%b8%bb%e6%a9%9f%e4%bc%ba%e6%9c%8d%e5%99%a8%e6%9e%b6%e8%a8%ad%e6%8a%80%e8%a1%93%ef%bc%89\/","title":{"rendered":"FTP\u6a94\u6848\u50b3\u8f38\u670d\u52d9\uff08Linux\u4e3b\u6a5f\u4f3a\u670d\u5668\u67b6\u8a2d\u6280\u8853\uff09"},"content":{"rendered":"<p><strong><span style=\"background-color: #ffff00; font-size: medium;\">FTP\u6a94\u6848\u50b3\u8f38\u670d\u52d9\uff08Linux\u4e3b\u6a5f\u4f3a\u670d\u5668\u67b6\u8a2d\u6280\u8853\uff09<\/span><\/strong><\/p>\n<p>Linux sqz \u4e0a\u7684\u6a94\u6848\u50b3\u8f38\u670d\u52d9\u9810\u8a2d\u662f\u4f7f\u7528 vsftp \u5957\u4ef6\uff0c\u88dd\u59a5\u6642\u7684\u9810\u8a2d\u72c0\u614b\u5982\u4e0b\uff1a<\/p>\n<p>1. \u4f7f\u7528 stand alone\u3000\u65b9\u5f0f\u63d0\u4f9b\u670d\u52d9<br \/>\n2. \u4efb\u4f55\u5408\u6cd5\u4f7f\u7528\u8005\u7686\u53ef\u4ee5\u767b\u5165\uff0c\u4e26\u5b58\u53d6\u81ea\u5df1\u5bb6\u76ee\u9304\u5e95\u4e0b\u7684\u6a94\u6848<br \/>\n3. \u95dc\u9589 anonymous<br \/>\n4. \u57fa\u65bc\u5b89\u5168\u56e0\u7d20\u4f7f\u7528\u767b\u5165\u5f8c\uff0c\u5176\u5bb6\u76ee\u9304\u5c31\u662f\u6839\u76ee\u9304 (chroot_local_user=YES )\uff0c\u56e0\u6b64\u7121\u6cd5\u5728\u300c\u7b2c\u4e09\u5730\u300d\u5efa\u7acb\u300c\u516c\u7528\u8cc7\u6599\u593e\u300d\u5f8c\uff0c\u4ee5 link \u7684\u65b9\u5f0f\u7d66\u5404\u4f7f\u7528\u8005\u5b58\u53d6\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/visdacom.com\/linux\/wp-content\/uploads\/2013\/04\/0938046037.jpg\" width=\"500\" height=\"380\" \/><strong><\/strong><\/p>\n<p>\u5b89\u88dd<\/p>\n<p>* \u5b89\u88dd<br \/>\nroot@dns:~# apt-get update<br \/>\nroot@dns:~# apt-get install vsftpd<\/p>\n<p>\u8a2d\u5b9a\u6aa2\u67e5<\/p>\n<p>* \u8acb\u6aa2\u67e5 \/etc\/vsftpd.conf \u5167\u7684\u8a2d\u5b9a\u503c\u662f\u5426\u8207\u4e0b\u9762\u6240\u5217\u4e00\u81f4<\/p>\n<p>#\u5728IPv4\u76e3\u807d\uff0c\u82e5\u8981\u6539\u6210 IPv6 \u76e3\u807d\uff0c\u4e00\u5b9a\u8981\u4fee\u6539\/etc\/rc.local\u5167\u7684 ip6tables \u4ee5\u53ca\u7d66\u4e88 fix ipv6 address<br \/>\nlisten=YES<br \/>\n#listen_ipv6=YES<br \/>\n#\u4e0d\u5141\u8a31anonymous\u516c\u5171\u4e0b\u8f09\u5340<br \/>\nanonymous_enable=NO<br \/>\n#\u5217\u51fa\u8cc7\u6599\u593e\u5167\u6a94\u6848\u8a73\u7d30\u5217\u8868<br \/>\ndirmessage_enable=YES<br \/>\n#\u4f7f\u7528\u672c\u6a5f\u6642\u9593<br \/>\nuse_localtime=YES<br \/>\n#\u4f7f\u7528\u8a18\u9304\u6a94<br \/>\nxferlog_enable=YES<br \/>\nxferlog_file=\/var\/log\/vsftpd.log<br \/>\n#\u555f\u52d5\u4e3b\u52d5\u5f0f\u50b3\u8f38<br \/>\nconnect_from_port_20=YES<br \/>\n#\u4e00\u4e9b\u5b89\u5168\u6027\u8a2d\u5b9a<br \/>\nsecure_chroot_dir=\/var\/run\/vsftpd\/empty<br \/>\npam_service_name=vsftpd<br \/>\nrsa_cert_file=\/etc\/ssl\/private\/vsftpd.pem<br \/>\n#\u555f\u7528\u672c\u6a5f User<br \/>\nlocal_enable=YES<br \/>\nchroot_local_user=YES<br \/>\nwrite_enable=YES<br \/>\nlocal_umask=022<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/visdacom.com\/linux\/wp-content\/uploads\/2019\/07\/Linux-Server-Project-13-650x433.jpg\" alt=\"\" class=\"alignnone size-medium wp-image-511\" width=\"650\" height=\"433\" \/><\/p>\n<p>\u5efa\u7acb\u516c\u7528\u8cc7\u6599\u593e<\/p>\n<p>\u5982\u679c\u5b78\u6821\u5e0c\u671b\u4f7f\u7528\u8005\u5728\u767b\u5165 FTP \u670d\u52d9\u5f8c\uff0c\u53ea\u80fd\u5b58\u53d6\u300c\u81ea\u5df1\u7684\u5bb6\u76ee\u9304\u300d\u53ca\u300c\u5171\u7528\u5340\u300d\uff0c\u800c\u770b\u4e0d\u5230\u5225\u4eba\u7684\u8cc7\u6599\u593e\u3002\u7b46\u8005\u4ee5 \/home\/ftp\/pub \u70ba\u516c\u7528\u5340\u70ba\u4f8b\uff0c\u5176\u4f5c\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>1. \u516c\u7528\u8cc7\u6599\u593e\u5efa\u5728\u5728 \/home\/ftp\/pub \u5e95\u4e0b<br \/>\nroot@dns:~# mkdir \/home\/ftp\/pub<br \/>\n2. \u6a94\u6848\u6b0a\u9650\u958b\u6210 1777\uff0c\u4f7f\u5171\u7528\u5340\u5167\u6bcf\u500b\u4eba\u7686\u53ef\u4e0a\u50b3\u4fee\u6539\u81ea\u5df1\u7684\u6771\u897f\uff0c\u4f46\u4e0d\u5f97\u4e92\u6539\u4ed6\u4eba\u7684<br \/>\nroot@dns:~# chmod 1777 \/home\/ftp\/pub \u3002<br \/>\n3. \u63a5\u8457\uff0c\u5728\u6bcf\u500b user \u7684\u5bb6\u76ee\u9304\u4e0b\u57f7\u884c\u4ee5\u4e0b\u5169\u500b\u52d5\u4f5c\uff08\u4ee5 root \u8eab\u4efd\uff09\uff0c\u4fbf\u53ef\u4ee5\u9054\u6210\u300c\u5171\u7528\u5340\u300d\u7684\u5efa\u7acb\u3002<br \/>\n* \u6bcf\u500b User\u4e5f\u9808\u5efa\u7acb pub \u8cc7\u6599\u593e\uff08\u82e5\u5df2\u5efa\u7acb\uff0c\u4e0d\u5fc5\u518d\u505a\uff09<br \/>\nroot@dns:~# mkdir \/home\/user\/pub<br \/>\n* \u628a \/home\/ftp\/pub \u639b\u8f09\u81f3 \/home\/user \u5e95\u4e0b\uff08\u6bcf\u6b21\u91cd\u958b\u6a5f\uff0c\u5fc5\u9808\u57f7\u884c\u4e00\u6b21\uff09<br \/>\nroot@dns:~# mount &#8211;bind \/home\/ftp\/pub \/home\/user\/pub<br \/>\n* \u4e0b mount \u6307\u4ee4\u6aa2\u8996<br \/>\nroot@dns:~# mount<\/p>\n<p>\u505a\u5b8c\u4e4b\u5f8c\uff0c\u5927\u5bb6\u6240\u5b58\u9032 pub \u8cc7\u6599\u593e\u7684\u6a94\u6848\uff0c\u5be6\u969b\u4e0a\u662f\u653e\u5728 \/home\/ftp\/pub\uff0c\u800c\u4e14\u7531\u65bc 1777 \u7684\u4f5c\u7528\uff0c\u5927\u5bb6\u4e0d\u53ef\u4e92\u76f8\u522a\u6539\u5c0d\u65b9\u7684\u3002\u53ea\u662f\uff0c\u9084\u6709\u5169\u500b\u554f\u984c\u5c1a\u5f85\u89e3\u6c7a\uff1a<\/p>\n<p>1. \u6bcf\u500b\u5e33\u865f\u90fd\u8981\u57f7\u884c\u4e00\u6b21\u9019\u6a23\u7684\u6307\u4ee4\uff0c\u8457\u5be6\u9ebb\u7169\u3002<br \/>\n2. \u4e0b\u6b21\u958b\u6a5f\u8981\u518d key in \u4e00\u6b21\u9019\u6a23\u7684\u6307\u4ee4<\/p>\n<p>\u4e00\u6b21\u628a\u639b\u9032\u6240\u6709\u4f7f\u7528\u8005<\/p>\n<p>\u7b46\u8005\u70ba\u89e3\u6c7a\u4e0a\u8ff0\u7684\u554f\u984c\uff0c\u5df2\u5beb\u4e00\u652f shell script \u5728\u6b64\uff1a \u6a94\u6848:Pubfolder.zip\u3002\u672c\u65b9\u6848\uff0c\u6703\u628a\u6240\u8f38\u5165\u7684\u300c\u5171\u7528\u8cc7\u6599\u593e\u300d\u5efa\u5728 \/home\/ftp \u5e95\u4e0b\u3002\u4ee5\u4e0b\u662f\u672c\u7a0b\u5f0f\u4e4b\u4f7f\u7528\u6ce8\u610f\u4e8b\u9805\uff1a<\/p>\n<p>* \u8981\u5171\u7528\u6642<br \/>\nroot@dns:~# pubfolder.sh -m \u5171\u7528\u8cc7\u6599\u593e\u540d\u7a31<br \/>\n\u82e5 \/home\/ftp \u5e95\u4e0b\u7121\u6b64\u8cc7\u6599\u593e\uff0c\u6703\u4ee5 1777 \u6b0a\u9650\u81ea\u52d5\u5efa\u7acb<br \/>\n* \u8981\u89e3\u9664\u5171\u7528\u6642<br \/>\nroot@dns:~# pubfolder.sh -u \u5171\u7528\u8cc7\u6599\u593e\u540d\u7a31<br \/>\n* \u4e0b\u6b21\u958b\u6a5f\u4e5f\u80fd\u81ea\u52d5\u639b\u8f09\u6642\uff0c\u8acb\u5728 rc.local \u7684\u5e95\u4e0b, exit 0 \u4e4b\u4e0a\uff0c\u52a0\u4e0a<br \/>\nroot@dns:~# vi \/etc\/rc.local<\/p>\n<p>&#8230;&#8230;<\/p>\n<p>pubfolder.sh -m \u5171\u7528\u8cc7\u6599\u593e\u540d\u7a31<\/p>\n<p>exit 0<\/p>\n<p>* \u4f7f\u7528\u300croot@dns:~# mount\u300d\u6307\u4ee4\u4f86\u6aa2\u8996\u639b\u8f09\u72c0\u614b\uff0c\u82e5\u6709\u4ee5\u4e0b\u5b57\u4e32\uff0c\u4ee3\u8868\u5171\u7528\u5340\u5df2\u639b\u8f09<\/p>\n<p>&#8230;<br \/>\n\/home\/ftp\/public on \/home\/tnc01\/public type none (rw,bind)<br \/>\n\/home\/ftp\/public on \/home\/tnc02\/public type none (rw,bind)<br \/>\n\/home\/ftp\/public on \/home\/tnc03\/public type none (rw,bind)<br \/>\n&#8230;<\/p>\n<p>* \u8a3b1\uff1a\u82e5 \u300c\/home\/ftp\/\u5171\u7528\u8cc7\u6599\u593e\u300d\u672a\u4e8b\u5148\u5efa\u7acb\uff0c\u800c\u7522\u751f\u6b64\u4e00\u932f\u8aa4\u8a0a\u606f\uff0c\u53ef\u4ee5\u4e0d\u7406\u6703\u300cspecial device \/home\/ftp\/xxxx does not exist\u300d<br \/>\n* \u8a3b2\uff1a\u9810\u8a2d\u6240\u5efa\u7acb\u7684\u5171\u7528\u8cc7\u6599\u593e\u6b0a\u9650\u70ba 1777 , \u82e5\u60f3\u6539\u70ba 777 \u8acb\u81ea\u884c\u4fee\u6539\u539f\u59cb\u78bc(\u628a\u552f\u4e00\u6709 1777 \u7684\u5730\u65b9\u6539\u6389)<br \/>\n* \u8a3b3\uff1amount \u6307\u4ee4\u7684\u904b\u7528\uff0c\u672c\u4f86\u5c31\u662f\u5169\u5730\u90fd\u8981\u6709\u5be6\u9ad4\u8cc7\u6599\u593e\uff0c\u610f\u5373\u672c\u5de5\u5177\u6703\u5728 \/home\/ftp \u5e95\u4e0b\u5efa\u4e00\u500b\u771f\u6b63\u7684\u5b58\u653e\u5340\uff0c\u4e5f\u6703\u5728\u5404\u500b User \u5e95\u4e0b\u5efa\u4e00\u500b\u540c\u540d\u300c\u7a7a\u7684\u300d\u7684\u8cc7\u6599\u593e\uff0c\u4f9b mount &#8211;bind \u7528\u3002<br \/>\n* \u8a3b4\uff1a\u5ef6\u7e8c\u8a3b3 \u6240\u63d0\uff0c\u5728\u4f7f\u7528 pubfolder.sh -u \u89e3\u9664\u5171\u7528\u5340\u4e4b\u5f8c\uff0c\u4e26\u4e0d\u6703\u628a\u5404\u5bb6\u76ee\u9304\u5e95\u4e0b\u7684\u90a3\u500b\u300c\u7a7a\u7684\u300d\u540c\u540d\u8cc7\u6599\u593e\u522a\u9664\uff0c\u53ef\u80fd\u6703\u9020\u6210\u60a8\u89ba\u5f97\u5171\u7528\u5340\u4e26\u6c92\u522a\u9664\u7684\u5047\u50cf\u3002<\/p>\n<p>\u6b64\u6a5f\u5236\u4e0brSync\u5099\u4efd\u6ce8\u610f\u4e8b\u9805<\/p>\n<p>\u7531\u65bc\u6211\u5011\u628a \/home\/ftp\/pub \u639b\u8f09\u81f3 \/home\/user\/pub \uff0c\u56e0\u6b64\uff0c\u4e8b\u5be6\u4e0a\u6240\u6709\u8cc7\u6599\u6a94\u6848\u662f\u5728 \/home\/ftp\/pub \u5e95\u4e0b\uff0c\u4f46 rsync \u7a0b\u5f0f\u4e26\u4e0d\u77e5\u9053\u9019\u4ef6\u4e8b\uff0c\u5728\u5099\u4efd\u57f7\u884c\u6642\uff0c\u6703\u628a\u6bcf\u500b\u4eba\u7684 pub \u7686\u8907\u88fd\u4e00\u4efd\uff0c\u9020\u6210 pub \u91cd\u8986\u5099\u4efd\u7684\u73fe\u8c61\u3002\u89e3\u6c7a\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>* \u4fee\u6539 \/root\/bk-Linux.sh\uff0c\u5728\u57f7\u884c rsync \u6307\u4ee4\u7684\u524d\u9762\u5148\u7f37\u8f09\u518d\u639b\u8f09\uff0c\u8209\u4f8b\u5982\u4e0b\uff1a<\/p>\n<p>#! \/bin\/sh<\/p>\n<p>\/root\/pubfolder.sh -u pub<\/p>\n<p>\/usr\/bin\/rsync -rvlHpogDtS &#8211;password-file=\/root\/rsyncd.secrets \/var\/lib\/mysql my_backup@163.26.x.x::mybk<br \/>\n\/usr\/bin\/rsync -rvlHpogDtS &#8211;password-file=\/root\/rsyncd.secrets \/var\/www yh_backup@163.26.x.x::mybk<br \/>\n&#8230;<\/p>\n<p>\/root\/pubfolder.sh -m pub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>FTP\u6a94\u6848\u50b3\u8f38\u670d\u52d9\uff08Linux\u4e3b\u6a5f\u4f3a\u670d\u5668\u67b6\u8a2d\u6280\u8853\uff09 Linux sqz \u4e0a\u7684\u6a94\u6848\u50b3\u8f38\u670d\u52d9\u9810\u8a2d\u662f\u4f7f\u7528 vsftp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":511,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[20],"class_list":["post-39","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/posts\/39"}],"collection":[{"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":0,"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/media\/511"}],"wp:attachment":[{"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/por.tw\/linux\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}