{"id":90303,"date":"2024-03-06T05:39:12","date_gmt":"2024-03-05T21:39:12","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=90303"},"modified":"2024-03-06T05:39:12","modified_gmt":"2024-03-05T21:39:12","slug":"establish-ssh-service","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/establish-ssh-service.html","title":{"rendered":"\u5efa\u7acbSSH\u4e4b\u514d\u5bc6\u767b\u9646"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6709\u4e00\u4e2a\u9879\u76ee\u8981\u6c42\u662f\u5728\u670d\u52a1\u5668\u4e2d\u5199\u4e00\u4e2aShell\u811a\u672c\uff0c\u4e3b\u8981\u7528\u6765\u5728\u673a\u5668B\u4e2d\u5b9a\u65f6\u5907\u4efd\u673a\u5668A\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\u3002\u73b0\u6709scp\u548cssh\u4e24\u4e2a\u73a9\u5177\u3002\u522b\u7684\u8fd8\u771f\u6ca1\u6709\u5176\u4ed6\u4ec0\u4e48\u4e1c\u897f\u4e86\u3002\u90a3\u5c31\u60f3\u76f4\u63a5\u7528scp\u53bb\u8fdc\u7a0b\u590d\u5236\u597d\u4e86\uff0c\u4f46\u662fscp\u590d\u5236\u7684\u65f6\u5019\u8fd8\u8981\u8f93\u5165\u5bc6\u7801\u3002\u90a3\u5c31\u641e\u641e\u8ba9\u4f7f\u7528scp\u7684\u65f6\u5019\u4e0d\u7528\u8f93\u5165\u5bc6\u7801\u597d\u4e86\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u4ee5\u4e0b\u8fdb\u5165\u6b63\u6587<\/p>\n

\u5ffd\u7565ssh\u5b89\u88c5scp\u5b89\u88c5\u8fc7\u7a0b\u3002\u9ed8\u8ba4\u8ba4\u4e3a\u5f53\u524d\u673a\u5668\u4e0e\u8fdc\u7a0b\u673a\u5668\u542b\u6709\u5b8c\u6574\u7684ssh,scp\u529f\u80fd<\/p>\n

\u9996\u5148\u5728\u673a\u5668B\u4e2d\u4f7f\u7528ssh-keygen -t rsa \u547d\u4ee4 \uff08\u60f3\u6765\u73a9git\u7684\u7ae5\u978b\u5e94\u8be5\u77e5\u9053\u5427~\uff09<\/p>\n

[hart02@hart02 .ssh]$ ssh-keygen -t rsa<\/pre>\n

\"\"<\/p>\n

Enter file in which to save the key (\/home\/hart02\/.ssh\/id_rsa)<\/pre>\n

\u76f4\u63a5\u6309enter\u952e<\/p>\n

Enter passphrase (empty for no passphrase):<\/pre>\n

\u610f\u601d\u662f\u8bf4\u8bf7\u8f93\u5165\u5bc6\u7801\uff0c\u5982\u679c\u4e0d\u8f93\u5165\u5219\u4e3a\u6ca1\u6709\u5bc6\u7801\u3002\u5f53\u7136\uff0c\u6211\u4eec\u4f7f\u7528\u7684enter\u952e~\u4e4b\u540e\u5c31\u662f\u91cd\u590d\u8f93\u5165\u5bc6\u7801\u4e86\u3002\u4e24\u6b21\u4e00\u5b9a\u8981\u4fdd\u6301\u4e00\u81f4\u54e6~\uff0c\u5982\u679c\u7b2c\u4e00\u6b21\u4e0d\u8f93\u5165\uff0c\u7b2c\u4e8c\u6b21\u4e5f\u8fd8\u8981\u8f93\u5165\u54e6~<\/p>\n

\u6ce8\uff1a\u673a\u5668\u5df2\u7ecf\u751f\u6210\u8fc7\u4e86\uff0c\u6240\u4ee5\u6b64\u65f6\u63d0\u793a\u8bf4<\/p>\n

\/home\/hart02\/.ssh\/id_rsa already exists.<\/pre>\n

\u8f93\u5165\u5b8c\u6210\u540e\u5c31\u4f1a\u51fa\u73b0\u8fd9\u6837\u7684\u754c\u9762\uff08\u6b64\u754c\u9762\u662f\u5728\u6d4b\u8bd5\u673a\u5668\u4e0a\u91cd\u65b0\u751f\u6210\u7684\u622a\u56fe,\u51e0\u4e2a\u91cd\u70b9\u7684\u4e1c\u897f\u5df2\u7ecf\u7740\u91cd\u6807\u5fd7\u51fa\u6765\u4e86\uff09
\n\"\"
\n\u4ece\u4e0a\u56fe\u4e2d\u6211\u4eec\u53ef\u4ee5\u4e86\u89e3\u5230\u751f\u6210\u7684\u516c\u79c1\u94a5\u5b58\u653e\u5728\/user\/.ssh\/\u76ee\u5f55\u4e0buser\u4e3a\u5f53\u524d\u767b\u9646\u7528\u6237\u5bb6\u76ee\u5f55\u3002
\n\u4e0b\u56fe\u4e2dauthorized_keys\u4e0d\u4f1a\u81ea\u52a8\u751f\u6210\u3002\u5728\u5f53\u524d\u673a\u5668B\u4e2d\u6682\u65f6\u6ca1\u6709\u4ec0\u4e48\u7528\u5904<\/p>\n

\"\"<\/p>\n

\u67e5\u770b.ssh\u76ee\u5f55\u4e0b\u6587\u4ef6<\/p>\n

\u73b0\u5728\u6211\u4eec\u5728\u673a\u5668A\u4e2d\u8fdb\u884c\u64cd\u4f5c\uff0c\u5176\u64cd\u4f5c\u5982\u4e0a\u8ff0\u6b65\u9aa4\u4e00\u81f4\u3002\u5f53\u751f\u6210\u5b8c\u6bd5\u65f6\uff0c\u6211\u4eectouch \u4e00\u4e2a\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u4e3aauthorized_keys
\n\"\"<\/p>\n

\u91cd\u8981\u7684\u6765\u4e86~~\uff1a<\/p>\n

\u5728\u673a\u5668B\u4e2d\u4f7f\u7528<\/p>\n

cat id_rsa.pub<\/pre>\n

\u67e5\u770b\u4e00\u4e0b\u516c\u94a5\uff0c\u7136\u540e\u590d\u5236\u8fd9\u4e00\u4e32\u4e1c\u897f~
\n\u5728\u673a\u5668A\u4e2d\uff0c<\/p>\n

vim authorized_keys<\/pre>\n

\u628a\u590d\u5236\u7684\u4e1c\u897f\u7c98\u8d34\u5230A\u673a\u5668\u4e2d\u7684\u8fd9\u4e2a\u6587\u4ef6\u91cc\u9762\u3002
\nESC -> :wq! -> enter \u4fdd\u5b58\u9000\u51fa
\n\"\"<\/p>\n

cat authorized_keys<\/pre>\n

\u786e\u4fdd\u5199\u5165\u6210\u529f<\/p>\n

chmod 600 authorized_keys<\/pre>\n

\u4fee\u6539\u6587\u4ef6\u6743\u9650
\n\"\"
\n\u4ee5\u4e0a\u6b65\u9aa4\u505a\u5b8c\u4e4b\u540e\u4e00\u5b9a\u8981\u505a\u4e00\u4e0b<\/p>\n

\/etc\/init.d\/sshd restart<\/pre>\n

\u628assh\u670d\u52a1\u91cd\u65b0\u542f\u52a8\u4e00\u4e0b\u3002
\n\"\"<\/p>\n

\u81f3\u6b64\u3002ssh\u514d\u5bc6\u767b\u9646\u914d\u7f6e\u5b8c\u6210\u3002\u8bf4\u7684\u597d\u542c\uff0c\u4e0d\u5982\u770b\u770b\u6548\u679c\uff1a<\/p>\n

\"\"<\/p>\n

OK,\u4e0b\u7ae0\u6765\u505ascp\u8fdc\u7a0b\u590d\u5236\u811a\u672c\u7684\u8bf4\u660e~<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.cnblogs.com\/tdg-yyx\/p\/8033840.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/establish-ssh-service.html<\/a>\u7f16\u8f91\uff1a\u51af\u745e\u6d9b\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u6709\u4e00\u4e2a\u9879\u76ee\u8981\u6c42\u662f\u5728\u670d\u52a1\u5668\u4e2d\u5199\u4e00\u4e2aShell\u811a\u672c\uff0c\u4e3b\u8981\u7528\u6765\u5728\u673a\u5668B\u4e2d\u5b9a\u65f6\u5907\u4efd\u673a\u5668A\u4e2d\u7684\u4e00\u4e9b\u6587\u4ef6\u3002\u73b0\u6709scp […]<\/p>\n","protected":false},"author":1329,"featured_media":90308,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-90303","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/90303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=90303"}],"version-history":[{"count":6,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/90303\/revisions"}],"predecessor-version":[{"id":290259,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/90303\/revisions\/290259"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/90308"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=90303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=90303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=90303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}