{"id":1445,"date":"2019-10-23T16:07:20","date_gmt":"2019-10-23T08:07:20","guid":{"rendered":"http:\/\/www.iooe.cn\/?p=1445"},"modified":"2019-10-23T16:08:21","modified_gmt":"2019-10-23T08:08:21","slug":"1445","status":"publish","type":"post","link":"https:\/\/www.iooe.cn\/index.php\/2019\/10\/23\/1445\/","title":{"rendered":"\u5173\u4e8e\u9650\u5236sftp\u767b\u5f55\u540e\uff0c \u76ee\u5f55\u6743\u9650\u95ee\u9898"},"content":{"rendered":"<h1 id=\"2147405285\">\u4e00\u3001\u73af\u5883\uff1a<a class=\"esa-anchor\" href=\"https:\/\/www.cnblogs.com\/xjnotxj\/p\/6912471.html#2147405285\">#<\/a><\/h1>\n<p>CentOS 6.8<br \/>\n\u4f7f\u7528 FileZilla \u8fdb\u884c sftp \u8fde\u63a5<\/p>\n<h1 id=\"3204497260\">\u4e8c\u3001\u80cc\u666f<a class=\"esa-anchor\" href=\"https:\/\/www.cnblogs.com\/xjnotxj\/p\/6912471.html#3204497260\">#<\/a><\/h1>\n<p>\u7ed9\u5916\u5305\u7684\u5de5\u4f5c\u4eba\u5458\u63d0\u4f9b\u6211\u53f8\u670d\u52a1\u5668\u7684<strong>\u67d0\u4e00\u76ee\u5f55<\/strong>\u7684\u8bbf\u95ee\uff08\u5305\u62ec\u8bfb\u5199\uff09\u6743\u9650\uff0c\u65b9\u4fbf\u4ed6\u4eec\u90e8\u7f72\u4ee3\u7801\u6587\u4ef6\u3002<\/p>\n<p>\u4e4b\u6240\u4ee5\u662f\u67d0\u4e00\u76ee\u5f55\u7684\u8bbf\u95ee\uff0c\u662f\u56e0\u4e3a SFTP \u7684\u7528\u6237\u767b\u5f55\u540e\uff0c\u9ed8\u8ba4\u662f\u80fd\u770b\u5230\u6574\u4e2a\u7cfb\u7edf\u7684\u6587\u4ef6\u76ee\u5f55\uff0c\u8fd9\u6837\u5f88\u4e0d\u5b89\u5168\u3002<\/p>\n<p>\u9898\u5916\u8bdd\uff1a\u5982\u679c\u662f\u9488\u5bf9 ftp \u7684\u7528\u6237\u6743\u9650\u7ba1\u7406\uff0c\u63a8\u8350\u4f7f\u7528 vsftpd\uff0c\u53ef\u901a\u8fc7 yum \u76f4\u63a5\u5b89\u88c5\u3002<\/p>\n<h1 id=\"3407289595\">\u4e09\u3001\u6b63\u6587<a class=\"esa-anchor\" href=\"https:\/\/www.cnblogs.com\/xjnotxj\/p\/6912471.html#3407289595\">#<\/a><\/h1>\n<h4 id=\"\u521b\u5efa\u65b0\u7528\u6237\">1\u3001\u521b\u5efa\u65b0\u7528\u6237<\/h4>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_0\">Copy<\/div>\n<pre><code class=\"hljs nginx\" id=\"copy_target_0\"><span class=\"hljs-attribute\">adduser<\/span> sftpuser1<\/code><\/pre>\n<blockquote><p>useradd \u548c adduser \u7684\u533a\u522b<br \/>\nuseradd \u53ea\u4f1a\u6dfb\u52a0\u4e00\u4e2a\u7528\u6237\uff0c\u5e76\u6ca1\u6709\u521b\u5efa\u5b83\u7684\u4e3b\u76ee\u5f55\uff0c\u9664\u4e86\u6dfb\u52a0\u4e00\u4e2a\u65b0\u7528\u6237\u4e4b\u5916\u4ec0\u4e48\u90fd\u6ca1\u6709\u3002\u8fd9\u4e2a\u7528\u6237\u751a\u81f3\u4e0d\u80fd\u767b\u5f55\uff0c\u56e0\u4e3a\u6ca1\u6709\u5bc6\u7801\u3002\u6240\u4ee5\u8fd9\u91cc\u9009\u62e9 adduser\u3002<\/p><\/blockquote>\n<h4 id=\"\u8bbe\u7f6e\u8be5\u7528\u6237\u5bc6\u7801\">2\u3001\u8bbe\u7f6e\u8be5\u7528\u6237\u5bc6\u7801<\/h4>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_1\">Copy<\/div>\n<pre><code class=\"hljs nginx\" id=\"copy_target_1\"><span class=\"hljs-attribute\">passwd<\/span> sftpuser1<\/code><\/pre>\n<blockquote><p>\u56de\u8f66\u540e\u518d\u8f93\u5165\u5bc6\u7801\u5373\u53ef<\/p><\/blockquote>\n<h4 id=\"\u7981\u6b62\u8be5\u7528\u6237\u767b\u5f55-ssh\">3\u3001\u7981\u6b62\u8be5\u7528\u6237\u767b\u5f55 SSH<\/h4>\n<p>\u56e0\u4e3a\u6211\u4eec\u53ea\u60f3\u8be5\u7528\u6237\u4f7f\u7528 SFTP\uff0c\u5e76\u4e0d\u9700\u8981\u8be5\u7528\u6237\u80fd\u767b\u5f55 SSH\uff0c\u5a01\u80c1\u5b89\u5168\u3002<\/p>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_2\">Copy<\/div>\n<pre><code class=\"hljs groovy\" id=\"copy_target_2\">usermod -s <span class=\"hljs-regexp\">\/bin\/<\/span><span class=\"hljs-literal\">false<\/span> sftpuser1<\/code><\/pre>\n<p>\u5c06<code>sftpuser1<\/code>\u7684 shell \u6539\u6210 \/bin\/false\u3002<\/p>\n<h4 id=\"\u4fee\u6539\u8be5\u7528\u6237\u7684\u5bb6\u76ee\u5f55\">4\u3001\u4fee\u6539\u8be5\u7528\u6237\u7684\u5bb6\u76ee\u5f55<\/h4>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_3\">Copy<\/div>\n<pre><code class=\"hljs haskell\" id=\"copy_target_3\"><span class=\"hljs-title\">usermod<\/span> -d \/<span class=\"hljs-class\"><span class=\"hljs-keyword\">data<\/span>\/wwwroot\/user1\/ sftpuser1<\/span><\/code><\/pre>\n<p>\u8fd9\u6837\u6bcf\u6b21\u7528\u6237\u8bbf\u95ee\u670d\u52a1\u5668\u90fd\u4f1a\u9ed8\u8ba4\u6253\u5f00<code>\/data\/wwwroot\/user1\/<\/code>\uff0c\u4f46\u8fd8\u662f\u53ef\u4ee5\u8df3\u51fa\u8fd9\u4e2a\u8bbf\u95ee\u5176\u5b83\u76ee\u5f55\uff0c\u9700\u8981\u8fdb\u884c\u4e0b\u9762\u4e00\u6b65\u7684\u64cd\u4f5c\u3002<\/p>\n<h4 id=\"\u8bbe\u7f6e-sshd_config\">5\u3001\u8bbe\u7f6e sshd_config\uff1a<\/h4>\n<p>\u6253\u5f00<code>sshd_config<\/code>\u6587\u4ef6<\/p>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_4\">Copy<\/div>\n<pre><code class=\"hljs nginx\" id=\"copy_target_4\"><span class=\"hljs-attribute\">vi<\/span> \/etc\/ssh\/sshd_config<\/code><\/pre>\n<p>\u627e\u5230 Subsystem sftp \u8fd9\u4e00\u884c\uff0c\u4fee\u6539\u6210\uff1a<\/p>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_5\">Copy<\/div>\n<pre><code class=\"hljs haskell\" id=\"copy_target_5\"><span class=\"hljs-type\">Subsystem<\/span> sftp internal-sftp\r\n<span class=\"hljs-type\">UsePAM<\/span> yes\r\n<span class=\"hljs-type\">Match<\/span> user sftpuser1\r\n<span class=\"hljs-type\">ForceCommand<\/span> internal-sftp\r\n<span class=\"hljs-type\">ChrootDirectory<\/span> \/<span class=\"hljs-class\"><span class=\"hljs-keyword\">data<\/span>\/wwwroot\/user1\/<\/span><\/code><\/pre>\n<p>\u5c06\u4e0a\u9762\u7684\u00a0<code>sftpuser1<\/code>\u00a0\u548c\u00a0<code>\/data\/wwwroot\/user1\/<\/code>\u00a0\u66ff\u6362\u6210\u4f60\u9700\u8981\u7684\u3002<\/p>\n<p>\u591a\u4e2a\u7528\u6237\u8bf7\u91cd\u590d\u914d\u7f6e\u8fd9\u4e09\u884c\uff1a<br \/>\nMatch user sftpuser2<br \/>\nForceCommand internal-sftp<br \/>\nChrootDirectory \/data\/wwwroot\/user2\/<\/p>\n<p>\u8fd9\u6837\u53ef\u4ee5\u4e3a\u4e0d\u540c\u7684\u7528\u6237\u8bbe\u7f6e\u4e0d\u540c\u7684\u9650\u5236\u76ee\u5f55\u3002<\/p>\n<h4 id=\"\u91cd\u65b0\u542f\u52a8-sshd-\u670d\u52a1\">6\u3001\u91cd\u65b0\u542f\u52a8 sshd \u670d\u52a1\uff1a<\/h4>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_6\">Copy<\/div>\n<pre><code class=\"hljs groovy\" id=\"copy_target_6\"><span class=\"hljs-regexp\">\/etc\/<\/span>init.d\/sshd restart<\/code><\/pre>\n<p>\u73b0\u5728\u7528 SFTP \u8f6f\u4ef6\u4f7f\u7528<code>sftpuser1<\/code>\u7528\u6237\u767b\u5f55\uff0c\u5c31\u53ef\u4ee5\u53d1\u73b0\u76ee\u5f55\u5df2\u7ecf\u88ab\u9650\u5b9a\u3001\u9501\u6b7b\u5728<code>\/data\/wwwroot\/user1\/<\/code>\u4e86\u3002<\/p>\n<hr \/>\n<h1 id=\"2351719987\">\u56db\u3001\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898<a class=\"esa-anchor\" href=\"https:\/\/www.cnblogs.com\/xjnotxj\/p\/6912471.html#2351719987\">#<\/a><\/h1>\n<h4 id=\"\u4fee\u6539sshd_config\u6587\u4ef6\u540e\u91cd\u542f-sshd\u62a5\u9519directive-usedns-is-not-allowed-within-a-match-block\">1\u3001\u4fee\u6539<code>sshd_config<\/code>\u6587\u4ef6\u540e\u91cd\u542f sshd\uff0c\u62a5\u9519\uff1aDirective &#8216;UseDNS&#8217; is not allowed within a Match block<\/h4>\n<p>\u8bed\u6cd5\u9519\u8bef\uff0c\u539f\u56e0\u672a\u77e5\uff0c\u53ea\u9700\u8981\u628a\u4e24\u6bb5\u914d\u7f6e\u7684\u4f4d\u7f6e\u4e92\u8c03\u5c31\u4e0d\u62a5\u9519\u4e86\u3002<\/p>\n<p>\u4fee\u6539\u524d\uff1a<\/p>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_7\">Copy<\/div>\n<pre><code class=\"hljs yaml\" id=\"copy_target_7\"><span class=\"hljs-string\">Subsystem<\/span> <span class=\"hljs-string\">sftp<\/span> <span class=\"hljs-string\">internal-sftp<\/span>\r\n<span class=\"hljs-string\">UsePAM<\/span> <span class=\"hljs-literal\">yes<\/span>\r\n<span class=\"hljs-string\">Match<\/span> <span class=\"hljs-string\">user<\/span> <span class=\"hljs-string\">sftpuser1<\/span>\r\n<span class=\"hljs-string\">ForceCommand<\/span> <span class=\"hljs-string\">internal-sftp<\/span>\r\n<span class=\"hljs-string\">ChrootDirectory<\/span> <span class=\"hljs-string\">\/data\/wwwroot\/user1\/<\/span>\r\n\r\n<span class=\"hljs-string\">UseDNS<\/span> <span class=\"hljs-literal\">no<\/span>\r\n<span class=\"hljs-string\">AddressFamily<\/span> <span class=\"hljs-string\">inet<\/span>\r\n<span class=\"hljs-string\">PermitRootLogin<\/span> <span class=\"hljs-literal\">yes<\/span>\r\n<span class=\"hljs-string\">SyslogFacility<\/span> <span class=\"hljs-string\">AUTHPRIV<\/span>\r\n<span class=\"hljs-string\">PasswordAuthentication<\/span> <span class=\"hljs-literal\">yes<\/span><\/code><\/pre>\n<p>\u4fee\u6539\u540e\uff1a<\/p>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_8\">Copy<\/div>\n<pre><code class=\"hljs yaml\" id=\"copy_target_8\"><span class=\"hljs-string\">UseDNS<\/span> <span class=\"hljs-literal\">no<\/span>\r\n<span class=\"hljs-string\">AddressFamily<\/span> <span class=\"hljs-string\">inet<\/span>\r\n<span class=\"hljs-string\">PermitRootLogin<\/span> <span class=\"hljs-literal\">yes<\/span>\r\n<span class=\"hljs-string\">SyslogFacility<\/span> <span class=\"hljs-string\">AUTHPRIV<\/span>\r\n<span class=\"hljs-string\">PasswordAuthentication<\/span> <span class=\"hljs-literal\">yes<\/span>\r\n\r\n<span class=\"hljs-string\">Subsystem<\/span> <span class=\"hljs-string\">sftp<\/span> <span class=\"hljs-string\">internal-sftp<\/span>\r\n<span class=\"hljs-string\">UsePAM<\/span> <span class=\"hljs-literal\">yes<\/span>\r\n<span class=\"hljs-string\">Match<\/span> <span class=\"hljs-string\">user<\/span> <span class=\"hljs-string\">sftpuser1<\/span>\r\n<span class=\"hljs-string\">ForceCommand<\/span> <span class=\"hljs-string\">internal-sftp<\/span>\r\n<span class=\"hljs-string\">ChrootDirectory<\/span> <span class=\"hljs-string\">\/data\/wwwroot\/user1\/<\/span><\/code><\/pre>\n<p>\u6ce8\uff1a\u5f53\u4f60\u51fa\u73b0\u8fd9\u4e2a\u9519\u8bef\u7684\u65f6\u5019\uff0csftp \u80af\u5b9a\u662f\u8fde\u4e0d\u4e0a\u4e86\u3002\u5982\u679c\u4f60\u4e60\u60ef\u7528 FileZilla \u53bb\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u90a3\u4e48\u6b64\u65f6\u4f60\u5f97\u4e0d\u60c5\u613f\u7684\u5207\u6362\u5230<br \/>\nshell\uff0c\u53bb\u7528 vi\/vim \u53bb\u4fee\u6539\u5b83\u4e86\u3002<\/p>\n<h4 id=\"\u65b0\u7528\u6237\u901a\u8fc7-sftp-\u8bbf\u95ee\u65f6\u6743\u9650\u4e0d\u5168\u53ea\u80fd\u8bfb\u4e0d\u80fd\u5199\">2\u3001\u65b0\u7528\u6237\u901a\u8fc7 sftp \u8bbf\u95ee\u65f6\uff0c\u6743\u9650\u4e0d\u5168\uff0c\u53ea\u80fd\u8bfb\u4e0d\u80fd\u5199<\/h4>\n<p>\u6211\u8bd5\u7740\u7528 root \u8d26\u53f7\u53bb\u628a\u8be5\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u6743\u9650\u6539\u6210 777\uff0c\u4f46\u662f\u4f1a\u51fa\u73b0\u8be5\u7528\u6237 sftp \u767b\u9646\u4e0d\u4e86\u7684\u60c5\u51b5\u3002\uff08\u62a5\u9519\uff1aServer unexpectedly closed network connection\uff09<\/p>\n<p>google \u4e86\u539f\u56e0\u5982\u4e0b\uff1a<\/p>\n<p>\u7ed9\u65b0\u7528\u6237\u7684\u5bb6\u76ee\u5f55\u7684\u6743\u9650\u8bbe\u5b9a\u6709\u4e24\u4e2a\u8981\u70b9\uff1a<\/p>\n<blockquote><p>1\u3001\u7531 ChrootDirectory \u6307\u5b9a\u7684\u76ee\u5f55\u5f00\u59cb\u4e00\u76f4\u5f80\u4e0a\u5230\u7cfb\u7edf\u6839\u76ee\u5f55\u4e3a\u6b62\u7684\u76ee\u5f55\u62e5\u6709\u8005\u90fd\u53ea\u80fd\u662f root<br \/>\n2\u3001\u7531 ChrootDirectory \u6307\u5b9a\u7684\u76ee\u5f55\u5f00\u59cb\u4e00\u76f4\u5f80\u4e0a\u5230\u7cfb\u7edf\u6839\u76ee\u5f55\u4e3a\u6b62\u90fd\u4e0d\u53ef\u4ee5\u5177\u6709\u7fa4\u7ec4\u5199\u5165\u6743\u9650\uff08\u6700\u5927\u6743\u9650 755\uff09<\/p><\/blockquote>\n<p>\u5982\u679c\u8fdd\u53cd\u4e86\u4e0a\u9762\u7684\u4e24\u6761\u8981\u6c42\uff0c\u90a3\u4e48\u5c31\u4f1a\u51fa\u73b0\u65b0\u7528\u6237\u8bbf\u95ee\u4e0d\u4e86 sftp<br \/>\n\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u6240\u4ee5<code>\/data\/wwwroot\/user1\/<\/code>\u53ca\u4e0a\u7ea7\u7684\u6240\u6709\u76ee\u5f55\u5c5e\u4e3b\u4e00\u5b9a\u8981\u662f<br \/>\nroot\uff0c\u5e76\u4e14\u7ec4\u6743\u9650\u548c\u516c\u5171\u6743\u9650\u4e0d\u80fd\u6709\u5199\u5165\u6743\u9650\uff0c<strong>\u5982\u679c\u4e00\u5b9a\u9700\u8981\u6709\u5199\u5165\u6743\u9650\uff0c\u90a3\u4eec\u53ef\u4ee5\u5728<code>\/data\/wwwroot\/user1\/<\/code>\u4e0b\u5efa\u7acb 777 \u6743\u9650\u7684\u6587\u4ef6\u5939<\/strong>\u3002<\/p>\n<div class=\"esa-clipboard-button\" data-tips=\"\u590d\u5236\u4ee3\u7801\" data-clipboard-target=\"#copy_target_9\">Copy<\/div>\n<pre><code class=\"hljs groovy\" id=\"copy_target_9\">mkdir <span class=\"hljs-regexp\">\/data\/<\/span>wwwroot<span class=\"hljs-regexp\">\/user1\/<\/span>upload\r\nchown -R <span class=\"hljs-string\">sftpuser1:<\/span>root <span class=\"hljs-regexp\">\/data\/<\/span>wwwroot<span class=\"hljs-regexp\">\/user1\/<\/span>upload<\/code><\/pre>\n<p>\u8fd9\u6837<code>sftpuser1<\/code>\u7528\u6237\u5c31\u53ef\u4ee5\u5728<code>\/data\/wwwroot\/user1\/upload<\/code>\u91cc\u968f\u610f\u8bfb\u5199\u6587\u4ef6\u4e86\u3002<\/p>\n<p>\u8fd9\u91cc\u5f88\u5168\u9762\u4e86\u3002 \u6211\u7684\u5b9e\u65bd\u8fc7\u7a0b\uff1a<\/p>\n<p>\/home\/\u4e0b\u662f\u8fd9\u4e2a\u9650\u5236\u76ee\u5f55<\/p>\n<p>\u5efa\u4e86\u7528\u6237\u540e\uff0c \u4f1a\u5728home\u4e0b\u5efa\u4e2a\u7528\u6237\u6b62\u5f55\u00a0 \u5982\uff1a ftpuser<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u73af\u5883\uff1a# CentOS 6.8 \u4f7f\u7528 FileZilla \u8fdb\u884c sftp \u8fde\u63a5 \u4e8c\u3001\u80cc\u666f# \u7ed9\u5916\u5305\u7684\u5de5\u4f5c\u4eba\u5458\u63d0\u4f9b\u6211\u53f8\u670d\u52a1\u5668\u7684\u67d0\u4e00\u76ee\u5f55\u7684\u8bbf\u95ee\uff08\u5305\u62ec\u8bfb\u5199\uff09\u6743\u9650\uff0c&#8230; <\/p>\n<div class='button-mores'><a href='https:\/\/www.iooe.cn\/index.php\/2019\/10\/23\/1445\/'> \u9605\u8bfb\u66f4\u591a&#8230; <\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts\/1445"}],"collection":[{"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1445"}],"version-history":[{"count":2,"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts\/1445\/revisions"}],"predecessor-version":[{"id":1447,"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts\/1445\/revisions\/1447"}],"wp:attachment":[{"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}