{"id":224732,"date":"2021-08-27T08:36:06","date_gmt":"2021-08-27T00:36:06","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=224732"},"modified":"2021-08-20T14:36:26","modified_gmt":"2021-08-20T06:36:26","slug":"manage-multi-ssh","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/manage-multi-ssh.html","title":{"rendered":"\u5982\u4f55\u7ba1\u7406\u591a\u4e2a SSH \u8fde\u63a5"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5982\u679c\u4f60\u4f7f\u7528\u591a\u4e2assh\u8fde\u63a5\uff0c\u7ba1\u7406\u548c\u8bb0\u4f4f IP \u5730\u5740\u3001\u7528\u6237\u540d\u548c\u5bc6\u7801\u3001\u79d8\u94a5\u4f1a\u6709\u70b9\u56f0\u96be\u3002\u5728\u672c\u6307\u5357\u4e2d\uff0c\u5c06\u5b66\u4e60\u4f7f\u7528 ssh \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u5b58\u50a8 ssh \u8fde\u63a5\u6240\u9700\u7684\u6240\u6709\u4fe1\u606f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u5e76\u6dfb\u52a0\u4e3b\u673a\u4fe1\u606f<\/strong><\/div>\n

\u6bcf\u53f0\u57fa\u4e8e Linux \/ Unix \u7684\u673a\u5668\u90fd\u6709\u4e00\u4e2a .ssh<\/code> \u6587\u4ef6\u5939\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u4fdd\u5b58 ssh \u5bc6\u94a5\u3002\u5728\u8fd9\u4e2a\u6587\u4ef6\u5939\u4e2d\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a config<\/code> \u7684\u6587\u4ef6\uff0c\u53ef\u4ee5\u5c06\u6240\u6709\u8fdc\u7a0b\u673a\u5668\u7684\u8be6\u7ec6\u4fe1\u606f\u653e\u5728\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002<\/p>\n

\u73b0\u5728\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5728 .ssh<\/code> \u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u7528\u6237\u4e3b\u76ee\u5f55\u4e2d\u6ca1\u6709.ssh<\/code>\u6587\u4ef6\u5939\uff0c\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u3002<\/p>\n

\r\n[root@localhost ~]# mkdir ~\/.ssh\r\n[root@localhost ~]# touch ~\/.ssh\/config \r\n<\/pre>\n

\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u4f8b\uff1a<\/p>\n

\r\n[root@localhost ~]# vim ~\/.ssh\/config \r\n\r\nHost mysql\r\n  HostName 192.168.0.12\r\n  Port 22\r\n  User root\r\n  IdentityFile ~\/.ssh\/common_pri_key\r\nHost web\r\n  HostName 192.168.43.137\r\n  Port 5658\r\n  User bob\r\nHost node1\r\n  HostName 192.168.43.131\r\n  Port 22\r\n  User root\r\n<\/pre>\n

\"\"
\n\u4e0a\u9762\u914d\u7f6e\u4e2d\uff0c\u8bbe\u7f6e\u6bcf\u53f0\u670d\u52a1\u5668\u7684\u8fde\u63a5\u540d\u79f0\uff0c\u8fde\u63a5\u5730\u5740\uff0c\u7aef\u53e3\u53f7\uff0c\u7528\u6237\u540d\uff0c\u8fd8\u53ef\u4ee5\u6307\u5b9a\u79d8\u94a5\u6587\u4ef6\u3002\u5982\u679c\u670d\u52a1\u5668\u6ca1\u6709\u57df\u540d\uff0c\u53ef\u4ee5\u63d0\u4f9b IP \u5730\u5740\u3002<\/p>\n

\u8fde\u63a5\u6d4b\u8bd5<\/strong><\/div>\n

\u73b0\u5728\u5df2\u7ecf\u8bbe\u7f6e\u4e86\u8fde\u63a5\u5230\u8fdc\u7a0b\u673a\u5668\u6240\u9700\u7684\u6240\u6709\u914d\u7f6e\u3002\u73b0\u5728\u9700\u8981\u8fde\u63a5\uff0c\u53ea\u9700\u8981\u4f7f\u7528ssh<\/code>\u547d\u4ee4\u540e\u9762\u52a0\u4e0a\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6307\u5b9a\u7684Host<\/code>\u540d\u79f0\u5373\u53ef\u8fde\u63a5\u3002<\/p>\n

\r\n[root@localhost ~]# ssh mysql\r\n<\/pre>\n

\"\"
\n\u56e0\u4e3aHost mysql<\/code>\u6211\u5df2\u7ecf\u63d0\u524d\u8bbe\u7f6e\u597d\u514d\u5bc6\u767b\u5f55\uff0c\u6240\u4ee5\u4e0d\u9700\u8981\u8f93\u5165\u5bc6\u7801\u5c31\u53ef\u4ee5\u8fde\u63a5\u4e86\u3002<\/p>\n

\u5b9a\u4e49\u5e38\u7528\u53c2\u6570<\/strong><\/div>\n

\u5982\u679c\u9700\u8981\u7ba1\u7406\u5927\u91cf\u670d\u52a1\u5668\uff0c\u5e76\u4e14\u6240\u6709\u670d\u52a1\u5668\u90fd\u5177\u6709\u76f8\u540c\u7684\u7528\u6237\u540d\u548c ssh \u5bc6\u94a5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5b9a\u4e49\u4e00\u7ec4\u516c\u5171\u53c2\u6570\u3002\u5982\u4e0b\uff1a<\/p>\n

\r\nHost dev\r\n  Hostname 192.168.43.137\r\n\r\nHost web.node1\r\n\r\nHost web.node2\r\n\r\nHost *\r\n  Port 4556\r\n  User jordan\r\n  IdentityFile ~\/.ssh\/jordan_privatekey\r\n\r\nHost web*\r\n  Port 4668\r\n  User james\r\n  IdentityFile ~\/.ssh\/james_privatekey\r\n<\/pre>\n

\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d Host *<\/code> \u8868\u793a\u8be5\u5757\u4e2d\u63cf\u8ff0\u7684\u53c2\u6570\u9002\u7528\u4e8e\u5168\u5c40\u7684\u670d\u52a1\u5668\u3002Host web*<\/code> \u8be5\u5757\u4e2d\u63cf\u8ff0\u7684\u53c2\u6570\u9002\u7528\u4e8e\u6240\u6709\u4ee5 web \u5f00\u5934\u7684\u4e3b\u673a\u5b9a\u4e49\u3002<\/p>\n

Host<\/code>\u90e8\u5206\u6307\u5b9a\u7684\u4e3b\u673a\u540d\u79f0\u5982\u679c\u4e0d\u80fd\u89e3\u6790\uff0c\u53ef\u4ee5\u5728\u4e0b\u9762\u6307\u5b9a\u4e00\u4e2aHostname\u53c2\u6570\uff0c\u5e76\u5199\u5165\u4ed6\u7684ip\u5730\u5740\u3002\u5982\u679cHost\u6307\u5b9a\u7684\u4e3b\u673a\u540d\u79f0\u80fd\u88ab\u89e3\u6790\uff0c\u53ef\u4ee5\u4e0d\u6dfb\u52a0Hostname<\/code>\u53c2\u6570\u3002<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u672c\u6307\u5357\u4e2d\u6211\u4eec\u5b66\u4e60\u4e86\u5982\u4f55\u4f7f\u7528 ssh \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u5b58\u50a8 ssh \u8fde\u63a5\u6240\u9700\u7684\u6240\u6709\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6bcf\u53f0\u57fa\u4e8e Linux \/ Unix \u7684\u673a\u5668\u90fd\u6709\u4e00\u4e2a .ssh \u6587\u4ef6\u5939\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u4fdd\u5b58 ssh \u5bc6\u94a5\u3002\u5728\u8fd9\u4e2a\u6587 […]<\/p>\n","protected":false},"author":309,"featured_media":224733,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-224732","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\/224732","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\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=224732"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224732\/revisions"}],"predecessor-version":[{"id":224737,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224732\/revisions\/224737"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/224733"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=224732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=224732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=224732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}