{"id":3010,"date":"2017-12-31T09:37:36","date_gmt":"2017-12-31T01:37:36","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=3010"},"modified":"2017-12-31T09:37:36","modified_gmt":"2017-12-31T01:37:36","slug":"centos%e4%b8%8bssh%e5%85%8d%e5%af%86%e7%a0%81%e7%99%bb%e5%bd%95%e4%b8%8d%e7%94%9f%e6%95%88%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/uncategorized\/centos%e4%b8%8bssh%e5%85%8d%e5%af%86%e7%a0%81%e7%99%bb%e5%bd%95%e4%b8%8d%e7%94%9f%e6%95%88%e9%97%ae%e9%a2%98\/","title":{"rendered":"CentOS\u4e0b\u201cssh\u514d\u5bc6\u7801\u767b\u5f55\u4e0d\u751f\u6548\u201d\u95ee\u9898"},"content":{"rendered":"<h3 id=\"-\">\u6458\u8981<\/h3>\n<blockquote><p>\u4e00\u822c\u4e3a\u4e86\u65b9\u4fbf\u8fd0\u7ef4\u7ba1\u7406\u90fd\u4f1a\u914d\u7f6essh\u514d\u5bc6\u767b\u5f55\uff0cssh\u514d\u5bc6\u767b\u5f55\u5b9e\u73b0\u4e5f\u5f88\u65b9\u4fbf\u3002\u4eca\u5929\u9047\u5230\u4e00\u4e2a\u5b8c\u6210\u4e86\u914d\u7f6e\u4e86\u5374\u4e0d\u80fd\u751f\u6548\u7684\u95ee\u9898\u3002<\/p><\/blockquote>\n<h3 id=\"-\">\u601d\u8003<\/h3>\n<p>\u9047\u5230\u8fd9\u4e2a\u95ee\u9898\u4e00\u822c\u6709\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ul>\n<li>authorized_keys\u6587\u4ef6\u662f\u5426\u542f\u7528<\/li>\n<li>.ssh \u548c authorized_keys \u6587\u4ef6\u6743\u9650\u95ee\u9898<\/li>\n<\/ul>\n<h3 id=\"-\">\u6392\u67e5<\/h3>\n<p>\u68c0\u67e5<code>AuthorizedKeysFile<\/code>\u914d\u7f6e\u662f\u5426\u542f\u7528<code>authorized_keys<\/code><\/p>\n<pre><code class=\"hljs css\"><span class=\"hljs-selector-tag\">root<\/span>@<span class=\"hljs-keyword\">pts<\/span>\/<span class=\"hljs-keyword\">1<\/span> $ cat \/etc\/ssh\/sshd_config |egrep AuthorizedKeysFile\r\nAuthorizedKeysFile    .ssh\/authorized_keys\r\n<\/code><\/pre>\n<p>\u6ca1\u6709\u95ee\u9898\uff0c\u7ee7\u7eed\u68c0\u67e5.ssh (700) \u548c authorized_keys(644) \u6743\u9650<\/p>\n<pre><code class=\"hljs ruby\">root@pts\/<span class=\"hljs-number\">1<\/span> $ getfacl \/root\/.ssh\/\r\n<span class=\"hljs-symbol\">getfacl:<\/span> Removing leading <span class=\"hljs-string\">'\/'<\/span> from absolute path names\r\n<span class=\"hljs-comment\"># file: root\/.ssh\/<\/span>\r\n<span class=\"hljs-comment\"># owner: root<\/span>\r\n<span class=\"hljs-comment\"># group: root<\/span>\r\nuser::rwx\r\ngroup::---\r\nother::---\r\n\r\nroot@pts\/<span class=\"hljs-number\">1<\/span> $ getfacl \/root\/.ssh\/authorized_keys\r\n<span class=\"hljs-symbol\">getfacl:<\/span> Removing leading <span class=\"hljs-string\">'\/'<\/span> from absolute path names\r\n<span class=\"hljs-comment\"># file: root\/.ssh\/authorized_keys<\/span>\r\n<span class=\"hljs-comment\"># owner: root<\/span>\r\n<span class=\"hljs-comment\"># group: root<\/span>\r\nuser::rw-\r\ngroup::---\r\nother::---\r\n<\/code><\/pre>\n<p><code>authorized_keys<\/code> \u6743\u9650\u4e0d\u5bf9\uff0c\u4fee\u6539\u4e00\u4e0b<code>chmod 644 authorized_keys<\/code><\/p>\n<p>\u518d\u6b21\u5c1d\u8bd5\u7ed3\u679c\u53d1\u73b0\u8fd8\u662f\u4e0d\u884c\u3002\u4f46\u662f\u8be5\u8bbe\u7f6e\u7684\u6743\u9650\u90fd\u8bbe\u7f6e\u4e86\u3002\u65e2\u7136<code>.ssh<\/code>\u76ee\u5f55\u548c\u5176\u4e0b\u6587\u4ef6\u7684\u6743\u9650\u90fdOK\u4e86\uff0c\u90a3\u5c31\u68c0\u67e5\u4e0b\u5176\u7236\u76ee\u5f55\u7684\u6743\u9650\uff0c\u4e5f\u5c31\u662f\u8fd9\u91cc\u7684<code>\/root<\/code>\u7684\u6743\u9650<\/p>\n<pre><code class=\"hljs ruby\">root@pts\/<span class=\"hljs-number\">1<\/span> $ getfacl \/root\/\r\n<span class=\"hljs-symbol\">getfacl:<\/span> Removing leading <span class=\"hljs-string\">'\/'<\/span> from absolute path names\r\n<span class=\"hljs-comment\"># file: root\/<\/span>\r\n<span class=\"hljs-comment\"># owner: ftpuser<\/span>\r\n<span class=\"hljs-comment\"># group: ftpuser<\/span>\r\nuser::r-x\r\ngroup::r-x\r\nother::---\r\n<\/code><\/pre>\n<p>\u53d1\u73b0\u8fd9\u91cc<code>\/root<\/code> \u7684\u5c5e\u4e3b\u90fd\u53d1\u751f\u4e86\u53d8\u5316\u3002\u4e3a\u4e86\u4e0d\u5f71\u54cd\u522b\u7684\u4e1a\u52a1\u60c5\u51b5\uff0c\u4fdd\u7559\u8fd9\u91cc\u7684ftpuser\u6743\u9650\uff0c\u5229\u7528<code>setfacl<\/code>\u6dfb\u52a0\u7279\u6b8aACL\u6743\u9650<\/p>\n<pre><code class=\"hljs ruby\">root@pts\/<span class=\"hljs-number\">1<\/span> $ chown -R <span class=\"hljs-symbol\">root:<\/span>root  \/root\/\r\nroot@pts\/<span class=\"hljs-number\">1<\/span> $ setfacl -m <span class=\"hljs-symbol\">u:<\/span><span class=\"hljs-symbol\">ftpuser:<\/span>rwx \/root\/\r\n\r\nroot@pts\/<span class=\"hljs-number\">1<\/span> $ getfacl \/root\/\r\n<span class=\"hljs-symbol\">getfacl:<\/span> Removing leading <span class=\"hljs-string\">'\/'<\/span> from absolute path names\r\n<span class=\"hljs-comment\"># file: root\/<\/span>\r\n<span class=\"hljs-comment\"># owner: root<\/span>\r\n<span class=\"hljs-comment\"># group: root<\/span>\r\nuser::rwx\r\n<span class=\"hljs-symbol\">user:<\/span><span class=\"hljs-symbol\">ftpuser:<\/span>rwx        <span class=\"hljs-comment\">#effective:r-x<\/span>\r\ngroup::r-x\r\nmask::r-x\r\nother::r-x\r\n<\/code><\/pre>\n<h3 id=\"-\">\u9644\u52a0<\/h3>\n<ul>\n<li>\u6743\u9650\u95ee\u9898\n<ul>\n<li>\/root 775<\/li>\n<li>\/root\/.ssh 700<\/li>\n<li>\/root\/.ssh\/authorized_keys 644<\/li>\n<\/ul>\n<\/li>\n<li>\u5f00\u542f\u6587\u4ef6<code>AuthorizedKeysFile .ssh\/authorized_keys<\/code><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981 \u4e00\u822c\u4e3a\u4e86\u65b9\u4fbf\u8fd0\u7ef4\u7ba1\u7406\u90fd\u4f1a\u914d\u7f6essh\u514d\u5bc6\u767b\u5f55\uff0cssh\u514d\u5bc6\u767b\u5f55\u5b9e\u73b0\u4e5f\u5f88\u65b9\u4fbf\u3002\u4eca\u5929\u9047\u5230\u4e00\u4e2a\u5b8c\u6210\u4e86\u914d\u7f6e\u4e86\u5374\u4e0d\u80fd\u751f &#8230; <a title=\"CentOS\u4e0b\u201cssh\u514d\u5bc6\u7801\u767b\u5f55\u4e0d\u751f\u6548\u201d\u95ee\u9898\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/uncategorized\/centos%e4%b8%8bssh%e5%85%8d%e5%af%86%e7%a0%81%e7%99%bb%e5%bd%95%e4%b8%8d%e7%94%9f%e6%95%88%e9%97%ae%e9%a2%98\/\" aria-label=\"\u9605\u8bfb CentOS\u4e0b\u201cssh\u514d\u5bc6\u7801\u767b\u5f55\u4e0d\u751f\u6548\u201d\u95ee\u9898\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3010","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3010","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=3010"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3010\/revisions"}],"predecessor-version":[{"id":3011,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3010\/revisions\/3011"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=3010"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=3010"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=3010"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}