{"id":790,"date":"2017-06-03T10:34:37","date_gmt":"2017-06-03T02:34:37","guid":{"rendered":"http:\/\/www.5x44.cn\/?p=790"},"modified":"2017-07-07T20:14:53","modified_gmt":"2017-07-07T12:14:53","slug":"%e8%bd%ac%e8%ae%be%e7%bd%ae-ssh-%e8%87%aa%e5%8a%a8%e7%99%bb%e9%99%86%ef%bc%88%e5%85%8d%e5%af%86%e7%a0%81%ef%bc%8c%e7%94%a8%e6%88%b7%e5%90%8d%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.5x44.cn\/?p=790","title":{"rendered":"[\u8f6c]\u8bbe\u7f6e SSH \u81ea\u52a8\u767b\u9646\uff08\u514d\u5bc6\u7801\uff0c\u7528\u6237\u540d\uff09"},"content":{"rendered":"<p>\u5176\u5b9e\u6211\u89c9\u5f97\u6bcf\u6b21\u4f7f\u7528SSH\u65f6\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u4e5f\u6ca1\u4ec0\u4e48\u4e0d\u597d\uff0c\u4f46\u662f\u5374\u88ab\u540c\u4e8b\u5404\u79cd\u65e0\u60c5\u7684\u9119\u89c6\u3002 T T<br \/>\n1\u3001\u521b\u5efa\u516c\u94a5\u3001\u516c\u94a5<br \/>\nssh-keygen -t rsa<br \/>\n\u65e0\u89c6\u5b83\u51fa\u6765\u7684\u4efb\u4f55\u63d0\u793a\uff0c\u6b22\u5feb\u7684\u4e00\u8def\u56de\u8f66\u5230\u5e95\u5427\u3002<br \/>\n2\u3001\u628a\u516c\u94a5 id_rsa.pub \u590d\u5236\u5230\u8fdc\u7a0b\u673a\u5668\u7684 \/home\/username\/.ssh\u76ee\u5f55 \u5e76\u547d\u540d\u4e3a authorized_keys<br \/>\n\u65b9\u6cd51: \u4e00\u6b65\u5230\u4f4d\uff1ascp ~\/.ssh\/id_rsa.pub username@hostname:~\/.ssh\/authorized_keys<\/p>\n<p>\u65b9\u6cd52: \u590d\u5236 scp ~\/.ssh\/id_rsa.pub username@hostname:~<br \/>\n\u767b\u9646 ssh username@hostname<br \/>\n\u8ffd\u52a0 cat id_rsa.pub &gt;&gt; .ssh\/authorized_keys<br \/>\n\u5404\u79cd\u624b\u6bb5\uff0c\u968f\u4f60\u5f00\u5fc3\uff0c\u53cd\u6b63\u590d\u5236\u8fc7\u53bb\u5c31\u6210\uff5e\u591a\u53f0\u8fdc\u7a0b\u4e3b\u673a\u5c31\u591a\u6b21\u590d\u5236\uff5e \u5982\u679c\u4f60\u672c\u673a\u767b\u9646\u7528\u6237\u548c\u8fdc\u7a0b\u767b\u9646\u7528\u6237\u4e00\u81f4\u7684\u8bdd\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5 ssh hostname\u76f4\u63a5\u767b\u9646\uff0c\u4e0b\u9762\u5c31\u4e0d\u7528\u770b\u4e86\u3002<\/p>\n<p>3\u3001\u89e3\u51b3\u672c\u5730\u767b\u9646\u7528\u6237\u4e0e\u8fdc\u7a0b\u767b\u9646\u7528\u6237\u4e0d\u4e00\u81f4<br \/>\n\u597d\u5427\uff0c\u8fd9\u4e8b\u5f88\u7ea0\u7ed3\uff0c\u867d\u7136\u4e0d\u7528\u8f93\u5165\u5bc6\u7801\u4e86\uff0c\u4f46\u662f\u8fd8\u5f97 ssh username@hostname \u6765\u767b\u9646\uff0c\u5f88\u4e0d\u723d\uff0c\u4f60\u61c2\u7684\u3002 \u5176\u5b9e\u89e3\u51b3\u4e5f\u5f88\u7b80\u5355\uff08but\u662f\u540c\u4e8b\u544a\u8bc9\u6211\u7684\uff0c\u8001\u8138\u4e00\u7ea2\uff09\uff0c\u4fee\u6539\u672c\u5730\u767b\u9646\u7528\u6237\u7684 ~\/.ssh\/config \u6587\u4ef6\uff0c\u5982\u679c\u6728\u6709\u7684\u8bdd\u5c31\u81ea\u4e2a\u513f\u5efa\u4e00\u4e2a\u5427\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<br \/>\nHost hostname<br \/>\nuser username<br \/>\nHost hostname2<br \/>\nuser username2<br \/>\n\u8fd9\u6837\uff0c\u672c\u5730\u548c\u8fdc\u7a0b\u767b\u9646\u7528\u6237\u540d\u4e0d\u4e00\u81f4\u4e5f\u53ef\u4ee5 ssh hostname \u767b\u9646\u4e86\u3002<br \/>\n\u6536\u5de5\u3002<\/p>\n<p>\u683c\u5f0f\u597d\u4e71\uff0c\u539f\u6587\u5728\u8fd9\u91cc <a href=\"http:\/\/liluo.org\/blog\/2011\/05\/ssh-automatic-login\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http:\/\/liluo.org\/blo<wbr \/>g\/2011\/05\/ssh-automa<wbr \/>tic-login\/<\/a><\/p>\n<pre>\u5728\u670d\u52a1\u5668\u6dfb\u52a0\u5b8c\u516c\u94a5\u4e4b\u540e\uff0cssh\u670d\u52a1\u5668\u7136\u540e\u62a5\u4e86\u8fd9\u4e2a\u9519\u8bef\r\nsign_and_send_pubkey: signing failed: agent refused operation\r\n\u7136\u540e\u6267\u884c\u4e86\u4ee5\u4e0b\u547d\u4ee4\u624d\u597d \r\neval \"$(ssh-agent -s)\" \r\nssh-add\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u5b9e\u6211\u89c9\u5f97\u6bcf\u6b21\u4f7f\u7528SSH\u65f6\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\u4e5f\u6ca1\u4ec0\u4e48\u4e0d\u597d\uff0c\u4f46\u662f\u5374\u88ab\u540c\u4e8b\u5404\u79cd\u65e0\u60c5\u7684\u9119\u89c6\u3002 T T 1\u3001\u521b\u5efa\u516c\u94a5\u3001\u516c\u94a5 ssh-keygen -t rsa \u65e0\u89c6\u5b83\u51fa\u6765&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/www.5x44.cn\/?p=790\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-790","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=790"}],"version-history":[{"count":4,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions"}],"predecessor-version":[{"id":814,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=\/wp\/v2\/posts\/790\/revisions\/814"}],"wp:attachment":[{"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.5x44.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}