{"id":313,"date":"2010-03-16T15:36:19","date_gmt":"2010-03-16T15:36:19","guid":{"rendered":""},"modified":"2013-02-07T12:10:29","modified_gmt":"2013-02-07T04:10:29","slug":"%e4%bf%ae%e6%94%b9selinux%e8%ae%be%e7%bd%ae%ef%bc%8c%e4%bd%bfvsftp%e5%9c%a8enforcing-security-enhance%e6%a8%a1%e5%bc%8f%e4%b8%8b%e6%ad%a3%e5%b8%b8%e8%bf%90%e8%a1%8c","status":"publish","type":"post","link":"https:\/\/dingxuan.info\/wp\/?p=313","title":{"rendered":"\u4fee\u6539SELinux\u8bbe\u7f6e\uff0c\u4f7fvsftp\u5728enforcing security enhance\u6a21\u5f0f\u4e0b\u6b63\u5e38\u8fd0\u884c"},"content":{"rendered":"<p>\u5f00\u4e86SELinux\u548c\u9632\u706b\u5899\uff0c\u6ca1\u60f3\u5230\u5f15\u51fa\u4e86vsftp\u7684\u95ee\u9898\u3002FTP\u767b\u5f55\u62a5\u9519\uff1a500 OOPS: cannot change directory\u3002\u4e0b\u9762\u6765\u770b\u770b\u4ea7\u751f\u8fd9\u4e2a\u95ee\u9898\u7684\u539f\u56e0\u548c\u5bf9\u7b56\u3002<!--more--><br \/><br \/>\u9996\u5148\uff0c\u5206\u6790\u4e00\u4e0b\u51b2\u7a81\u539f\u56e0\uff1a<br \/>1. \u4e3a\u9501\u5b9a\u7528\u6237\u5728\u81ea\u5df1\u7684home\u76ee\u5f55\u4e2d\uff0c\u5728vsftpd.conf\u6253\u5f00chroot_local_user\u3002<br \/>\u8fd9\u6837FTP\u767b\u5f55\u7528\u6237\u7684\u201c\/\u201d\uff0c\u5c31\u662fpasswd\u4e2d\u7684home path\uff0c\u6bd4\u5982\/var\/www\/a.com\/\u3002\u907f\u514dFTP\u7528\u6237\u8dd1\u5230\/etc\u4e71\u95ef\u3002\u8fd9\u6837\u8bbe\u7f6e\u8fc7\uff0cFTP\u767b\u5f55\u65f6\uff0c\u4f1a\u81ea\u52a8\u6267\u884cCWD \/var\/www\/html\/www.xxx.com\uff0c\u5e76\u4e14\u628a\u8fd9\u4e2a\u76ee\u5f55\u8bbe\u7f6e\u4e3aFTP\u8fdb\u7a0b\u7684\u6839\u76ee\u5f55\uff0c\u7528\u6237\u5c31\u65e0\u6cd5\u79bb\u5f00\u4e86\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">vi \/etc\/vsftpd\/vsftpd.conf<\/p>\n<h1 class=\"wp-block-heading\">You may specify an explicit list of local users to chroot() to their home<\/h1>\n<h1 class=\"wp-block-heading\">directory. If chroot_local_user is YES, then this list becomes a list of<\/h1>\n<h1 class=\"wp-block-heading\">users to NOT chroot().<\/h1>\n<p>chroot_local_user=YES<\/p>\n<h1 class=\"wp-block-heading\">chroot_list_enable=YES<\/h1>\n<h1 class=\"wp-block-heading\">(default follows)<\/h1>\n<h1 class=\"wp-block-heading\">chroot_list_file=\/etc\/vsftpd\/chroot_list<\/h1>\n<h1 class=\"wp-block-heading\">\u5f53\u7136\u4e5f\u53ef\u4ee5\u7528chroot_list_enable=YES\u7684\u529e\u6cd5\u3002\u4f46\u8981\u9010\u4e2a\u5728chroot_list\u4e2d\u6307\u5b9aFTP\u7528\u6237\u540d\uff0c\u5f88\u9ebb\u70e6\u3002\u4e5f\u5bb9\u6613\u51fa\u73b0\u758f\u6f0f\u3002\u6240\u4ee5\u8fd8\u662f\u63a8\u8350\u7528chroot_local_user\u6765\u9650\u5236\u3002<\/h1>\n<p><\/pre>\n<br \/><br \/><br \/>2. \u4e0b\u9762\uff0c\u95ee\u9898\u5c31\u51fa\u6765\u4e86\u3002\u6253\u5f00SELinux\u540e\uff0cSELinux\u4f1a\u963b\u6b62ftp daemon\u8bfb\u53d6\u7528\u6237home\u76ee\u5f55\u3002\u6240\u4ee5FTP\u4f1a\u7529\u51fa\u4e00\u53e5 \u201c500 OOPS: cannot change directory\u201d\u3002\u65e0\u6cd5\u8fdb\u5165\u76ee\u5f55\uff0c\u51fa\u9519\u9000\u51fa\u3002<br \/><br \/>\u89e3\u51b3\u529e\u6cd5\u6709\u4e24\u4e2a\uff1a<br \/><br \/>1. \u964d\u4f4eSELinux\u5b89\u5168\u7ea7\u522b\uff0c\u628aenforcing\u964d\u4f4e\u5230permissive <br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">vi \/etc\/sysconfig\/selinux<\/p>\n<h1 class=\"wp-block-heading\">This file controls the state of SELinux on the system.<\/h1>\n<h1 class=\"wp-block-heading\">SELINUX= can take one of these three values:<\/h1>\n<p>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; enforcing - SELinux security policy is enforced.\n#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; permissive - SELinux prints warnings instead of enforcing.\n#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; disabled - SELinux is fully disabled.\nSELINUX=permissive\n<\/pre>\n<br \/>\u8fd9\u65f6FTP\u7684\u767b\u5f55\u529f\u80fd\u5c31\u6b63\u5e38\u4e86\u3002\u4f46\u964d\u4f4e\u6574\u4f53\u7cfb\u7edf\u5b89\u5168\u4f5c\u4e3a\u4ee3\u4ef7\u6765\u89e3\u51b3\u4e00\u4e2a\u5c0f\u95ee\u9898\uff0c\u8fd9\u603b\u4e0d\u662f\u6700\u4f73\u65b9\u6848\u3002<br \/><br \/>2. \u7ecf\u8fc7\u7814\u7a76\uff0c\u53c8\u627e\u5230\u4e86\u53e6\u4e00\u4e2a\u66f4\u7406\u60f3\u7684\u529e\u6cd5\u3002\u9996\u5148\u67e5\u770bSELinux\u4e2d\u6709\u5173FTP\u7684\u8bbe\u7f6e\u72b6\u6001\uff1a<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">getsebool -a&#124;grep ftp<\/p>\n<p>allow_ftpd_anon_write --&gt; off\nallow_ftpd_full_access --&gt; off\nallow_ftpd_use_cifs --&gt; off\nallow_ftpd_use_nfs --&gt; off\nallow_tftp_anon_write --&gt; off\nftp_home_dir --&gt; off\nftpd_connect_db --&gt; off\nftpd_disable_trans --&gt; on\nftpd_is_daemon --&gt; on\nhttpd_enable_ftp_server --&gt; off\ntftpd_disable_trans --&gt; off\n<\/pre>\n<br \/><br \/>\u7ecf\u8fc7\u5c1d\u8bd5\u53d1\u73b0\uff0c\u6253\u5f00ftp_home_dir\u6216\u8005 ftpd_disable_trans\u3002\u90fd\u53ef\u4ee5\u8fbe\u5230\u5728enforcing\u7ea7\u522b\u4e0b\uff0c\u5141\u8bb8FTP\u6b63\u5e38\u767b\u5f55\u7684\u6548\u679c\u3002<br \/><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsetsebool -P ftp_home_dir 1\n#CentOS6\u91cc\uff0c\u662f\u8fd9\u6837\nsetsebool -P allow_ftpd_full_access 1<\/p>\n<p>service vsftpd restart<\/pre>\n<br \/>\u52a0-P\u662f\u4fdd\u5b58\u9009\u9879\uff0c\u6bcf\u6b21\u91cd\u542f\u65f6\u4e0d\u5fc5\u91cd\u65b0\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\u4e86\u3002\u6700\u540e\u522b\u5fd8\u4e86\u5728\/etc\/sysconfig\/selinux\u4e2d\uff0c\u4fee\u6539SELINUX=enforcing\u3002<br \/><br \/><\/p>","protected":false},"excerpt":{"rendered":"<p>\u5f00\u4e86SELinux\u548c\u9632\u706b\u5899\uff0c\u6ca1\u60f3\u5230\u5f15\u51fa\u4e86vsftp\u7684\u95ee\u9898\u3002FTP\u767b\u5f55\u62a5\u9519\uff1a500 OOPS: cannot c &hellip; <a href=\"https:\/\/dingxuan.info\/wp\/?p=313\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u4fee\u6539SELinux\u8bbe\u7f6e\uff0c\u4f7fvsftp\u5728enforcing security enhance\u6a21\u5f0f\u4e0b\u6b63\u5e38\u8fd0\u884c<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[117],"tags":[78],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-network","tag-linux"],"_links":{"self":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":0,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions"}],"wp:attachment":[{"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dingxuan.info\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}