{"id":67,"date":"2024-11-02T09:39:50","date_gmt":"2024-11-02T01:39:50","guid":{"rendered":"http:\/\/ddtek.cn\/?p=67"},"modified":"2024-11-02T09:40:14","modified_gmt":"2024-11-02T01:40:14","slug":"%e5%9c%a8centos%e4%b8%ad%e5%88%9b%e5%bb%ba%e6%96%b0%e7%94%a8%e6%88%b7%e5%b9%b6%e4%b8%ba%e5%85%b6%e8%ae%be%e7%bd%aessh%e8%ae%bf%e9%97%ae%e6%9d%83%e9%99%90","status":"publish","type":"post","link":"https:\/\/ddtek.cn\/index.php\/2024\/11\/02\/%e5%9c%a8centos%e4%b8%ad%e5%88%9b%e5%bb%ba%e6%96%b0%e7%94%a8%e6%88%b7%e5%b9%b6%e4%b8%ba%e5%85%b6%e8%ae%be%e7%bd%aessh%e8%ae%bf%e9%97%ae%e6%9d%83%e9%99%90\/","title":{"rendered":"\u5728CentOS\u4e2d\u521b\u5efa\u65b0\u7528\u6237\u5e76\u4e3a\u5176\u8bbe\u7f6eSSH\u8bbf\u95ee\u6743\u9650"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728CentOS\u4e2d\u521b\u5efa\u65b0\u7528\u6237\u5e76\u4e3a\u5176\u8bbe\u7f6eSSH\u8bbf\u95ee\u6743\u9650\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u521b\u5efa\u65b0\u7528\u6237\uff1a<br>sudo adduser newuser<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u8bbe\u7f6e\u5bc6\u7801\uff1a<br>sudo passwd newuser<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u4e3a\u65b0\u7528\u6237\u521b\u5efaSSH\u76ee\u5f55\uff08\u5982\u679c\u4e0d\u5b58\u5728\uff09\uff1a<br>sudo mkdir \/home\/newuser\/.ssh<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4\u3001\u66f4\u6539\u76ee\u5f55\u6743\u9650\uff08\u4ec5\u6240\u6709\u8005\u6709\u6743\u8bbf\u95ee\uff09\uff1a<br>sudo chmod 700 \/home\/newuser\/.ssh<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5\u3001\u4e3a\u65b0\u7528\u6237\u6dfb\u52a0SSH\u516c\u94a5\uff1a<br>\u9996\u5148\uff0c\u5728\u4f60\u7684\u7535\u8111\u4e0a\u751f\u6210SSH\u516c\u94a5\uff08\u5982\u679c\u8fd8\u6ca1\u6709\uff09\uff1a<br>ssh-keygen<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001\u7136\u540e\uff0c\u5c06\u516c\u94a5\u590d\u5236\u5230\u670d\u52a1\u5668\u4e0a\uff1a<br>ssh-copy-id newuser@your_server_ip<br>\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86 ssh-copy-id \u5de5\u5177\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u4f60\u53ef\u4ee5\u624b\u52a8\u590d\u5236\u516c\u94a5\u5230\u670d\u52a1\u5668\uff1a<br>cat ~\/.ssh\/id_rsa.pub | sudo tee -a \/home\/newuser\/.ssh\/authorized_keys<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7\u3001\u66f4\u6539 authorized_keys \u6587\u4ef6\u6743\u9650\uff08\u4ec5\u6240\u6709\u8005\u6709\u6743\u9650\u8bfb\u5199\uff09\uff1a<br>sudo chmod 600 \/home\/newuser\/.ssh\/authorized_keys<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">8\u3001\u914d\u7f6eSSH\u670d\u52a1\u5668\u5141\u8bb8\u5bc6\u94a5\u8ba4\u8bc1\uff1a<br>\u7f16\u8f91 \/etc\/ssh\/sshd_config \u6587\u4ef6\uff0c\u786e\u4fdd\u4ee5\u4e0b\u884c\u672a\u88ab\u6ce8\u91ca\u4e14\u8bbe\u7f6e\u4e3a yes\uff1a<br>PubkeyAuthentication yes<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">9\u3001\u5982\u679c\u4f60\u505a\u4e86\u4efb\u4f55\u66f4\u6539\uff0c\u8bf7\u91cd\u542fSSH\u670d\u52a1\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<br>sudo systemctl restart sshd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u73b0\u5728\uff0c\u65b0\u7528\u6237\u5e94\u8be5\u80fd\u591f\u901a\u8fc7SSH\u4f7f\u7528\u5176\u79c1\u94a5\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u767b\u5f55\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728CentOS\u4e2d\u521b\u5efa\u65b0\u7528\u6237\u5e76\u4e3a\u5176\u8bbe\u7f6eSSH\u8bbf\u95ee\u6743\u9650\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1\u3001\u521b\u5efa\u65b0\u7528\u6237\uff1asudo addus &#8230; <a title=\"\u5728CentOS\u4e2d\u521b\u5efa\u65b0\u7528\u6237\u5e76\u4e3a\u5176\u8bbe\u7f6eSSH\u8bbf\u95ee\u6743\u9650\" class=\"read-more\" href=\"https:\/\/ddtek.cn\/index.php\/2024\/11\/02\/%e5%9c%a8centos%e4%b8%ad%e5%88%9b%e5%bb%ba%e6%96%b0%e7%94%a8%e6%88%b7%e5%b9%b6%e4%b8%ba%e5%85%b6%e8%ae%be%e7%bd%aessh%e8%ae%bf%e9%97%ae%e6%9d%83%e9%99%90\/\" aria-label=\"\u9605\u8bfb \u5728CentOS\u4e2d\u521b\u5efa\u65b0\u7528\u6237\u5e76\u4e3a\u5176\u8bbe\u7f6eSSH\u8bbf\u95ee\u6743\u9650\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-67","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/posts\/67","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":1,"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":68,"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/68"}],"wp:attachment":[{"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ddtek.cn\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}