{"id":8699,"date":"2022-08-07T09:21:36","date_gmt":"2022-08-07T01:21:36","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=8699"},"modified":"2022-08-07T13:19:43","modified_gmt":"2022-08-07T05:19:43","slug":"centos-rhel-ssh","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos-rhel-ssh.html","title":{"rendered":"\u5728CentOS\/RHEL\u4e0a\u8bbe\u7f6eSSH\u514d\u5bc6\u7801\u767b\u5f55"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4f5c\u4e3a\u7cfb\u7edf\u7ba1\u7406\u5458\uff0c\u4f60\u8ba1\u5212\u5728 Linux \u4e0a\u4f7f\u7528 OpenSSH\uff0c\u5b8c\u6210\u65e5\u5e38\u5de5\u4f5c\u7684\u81ea\u52a8\u5316\uff0c\u6bd4\u5982\u6587\u4ef6\u4f20\u8f93\u3001\u5907\u4efd\u6570\u636e\u5e93\u8f6c\u50a8\u6587\u4ef6\u5230\u53e6\u4e00\u53f0\u670d\u52a1\u5668\u7b49\u3002\u4e3a\u5b9e\u73b0\u8be5\u76ee\u6807\uff0c\u4f60\u9700\u8981\u4ece\u4e3b\u673a A \u80fd\u81ea\u52a8\u767b\u5f55\u5230\u4e3b\u673a B\u3002\u81ea\u52a8\u767b\u5f55\u4e5f\u5c31\u662f\u8bf4\uff0c\u8981\u5728 shell \u811a\u672c\u4e2d\u4f7f\u7528ssh\uff0c\u800c\u65e0\u9700\u8981\u8f93\u5165\u4efb\u4f55\u5bc6\u7801\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"linux8899\"<\/p>\n

\u672c\u6587\u4f1a\u544a\u8bc9\u4f60\u600e\u6837\u5728 CentOS\/RHEL \u4e0a\u8bbe\u7f6e SSH \u514d\u5bc6\u7801\u767b\u5f55\u3002\u81ea\u52a8\u767b\u5f55\u914d\u7f6e\u597d\u4ee5\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b83\u4f7f\u7528 SSH (Secure Shell)\u548c\u5b89\u5168\u590d\u5236 (SCP)\u6765\u79fb\u52a8\u6587\u4ef6\u3002<\/p>\n

SSH \u662f\u5f00\u6e90\u7684\uff0c\u662f\u7528\u4e8e\u8fdc\u7a0b\u767b\u5f55\u7684\u6700\u4e3a\u53ef\u9760\u7684\u7f51\u7edc\u534f\u8bae\u3002\u7cfb\u7edf\u7ba1\u7406\u5458\u7528\u5b83\u6765\u6267\u884c\u547d\u4ee4\uff0c\u4ee5\u53ca\u901a\u8fc7 SCP \u534f\u8bae\u5728\u7f51\u7edc\u4e0a\u5411\u53e6\u4e00\u53f0\u7535\u8111\u4f20\u8f93\u6587\u4ef6\u3002<\/p>\n

\u901a\u8fc7\u914d\u7f6e SSH \u514d\u5bc6\u7801\u767b\u5f55\uff0c\u4f60\u53ef\u4ee5\u4eab\u53d7\u5230\u5982\u4e0b\u7684\u4fbf\u5229\uff1a<\/p>\n

\u25c6\u7528\u811a\u672c\u5b9e\u73b0\u65e5\u5e38\u5de5\u4f5c\u7684\u81ea\u52a8\u5316\u3002<\/p>\n

\u25c6\u589e\u5f3a Linux \u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002\u8fd9\u662f\u9632\u8303\u865a\u62df\u4e13\u7528\u670d\u52a1\u5668(VPS)\u906d\u53d7\u66b4\u529b\u7834\u89e3\u653b\u51fb\u7684\u4e00\u4e2a\u63a8\u8350\u7684\u65b9\u6cd5\uff0cSSH \u5bc6\u94a5\u5355\u51ed\u66b4\u529b\u7834\u89e3\u662f\u51e0\u4e4e\u4e0d\u53ef\u653b\u7834\u7684\u3002<\/p>\n

\u4ec0\u4e48\u662f Ssh-Keygen<\/strong><\/div>\n

ssh-keygen \u662f\u4e00\u4e2a\u7528\u6765\u751f\u6210\u3001\u521b\u5efa\u548c\u7ba1\u7406 SSH \u8ba4\u8bc1\u7528\u7684\u516c\u79c1\u94a5\u7684\u5de5\u5177\u3002\u901a\u8fc7 ssh-keygen \u547d\u4ee4\uff0c\u7528\u6237\u53ef\u4ee5\u521b\u5efa\u652f\u6301SSH1 \u548c SSH2 \u4e24\u4e2a\u534f\u8bae\u7684\u5bc6\u94a5\u3002ssh-keygen \u4e3a SSH1 \u534f\u8bae\u521b\u5efa RSA \u5bc6\u94a5\uff0cSSH2 \u5219\u53ef\u4ee5\u662f RSA \u6216 DSA\u3002<\/p>\n

\u4ec0\u4e48\u662f Ssh-Copy-Id<\/strong><\/div>\n

ssh-copy-id \u662f\u7528\u6765\u5c06\u672c\u5730\u516c\u94a5\u62f7\u8d1d\u5230\u8fdc\u7a0b\u7684 authorized_keys \u6587\u4ef6\u7684\u811a\u672c\u547d\u4ee4\uff0c\u5b83\u8fd8\u4f1a\u5c06\u8eab\u4efd\u6807\u8bc6\u6587\u4ef6\u8ffd\u52a0\u5230\u8fdc\u7a0b\u673a\u5668\u7684 ~\/.ssh\/authorized_keys \u6587\u4ef6\u4e2d\uff0c\u5e76\u7ed9\u8fdc\u7a0b\u4e3b\u673a\u7684\u7528\u6237\u4e3b\u76ee\u5f55\u9002\u5f53\u7684\u7684\u6743\u9650\u3002<\/p>\n

SSH \u5bc6\u94a5<\/strong><\/div>\n

SSH \u5bc6\u94a5\u4e3a\u767b\u5f55 Linux \u670d\u52a1\u5668\u63d0\u4f9b\u4e86\u66f4\u597d\u4e14\u5b89\u5168\u7684\u673a\u5236\u3002\u8fd0\u884c ssh-keygen \u540e\uff0c\u5c06\u4f1a\u751f\u6210\u516c\u79c1\u5bc6\u94a5\u5bf9\u3002\u4f60\u53ef\u4ee5\u5c06\u516c\u94a5\u653e\u7f6e\u5230\u4efb\u610f\u670d\u52a1\u5668\uff0c\u4ece\u6301\u6709\u79c1\u94a5\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\u5230\u670d\u52a1\u5668\u7684\u65f6\uff0c\u4f1a\u7528\u5b83\u6765\u89e3\u9501\u3002\u4e24\u8005\u5339\u914d\u65f6\uff0c\u7cfb\u7edf\u65e0\u9700\u5bc6\u7801\u5c31\u80fd\u89e3\u9664\u9501\u5b9a\u3002<\/p>\n

\u5728 CentOS \u548c RHEL \u4e0a\u8bbe\u7f6e\u514d\u5bc6\u7801\u767b\u5f55 SSH<\/strong><\/div>\n

\u4ee5\u4e0b\u6b65\u9aa4\u5728 CentOS 5\/6\/7\u3001RHEL 5\/6\/7 \u548c Oracle Linux 6\/7 \u4e0a\u6d4b\u8bd5\u901a\u8fc7\u3002<\/p>\n

\u8282\u70b91\uff1a192.168.0.9 \u8282\u70b92 : 192.168.0.10<\/p>\n

\u6b65\u9aa4\u4e00 :<\/h3>\n

\u6d4b\u8bd5\u8282\u70b91\u5230\u8282\u70b92\u7684\u8fde\u63a5\u548c\u8bbf\u95ee\uff1a<\/p>\n

[root@node1 ~]# ssh root@192.168.0.10\r\nThe authenticity of host '192.168.0.10 (192.168.0.10)' can't be established.\r\nRSA key fingerprint is 6d:8f:63:9b:3b:63:e1:72:b3:06:a4:e4:f4:37:21:42.\r\nAre you sure you want to continue connecting (yes\/no)? yes\r\nWarning: Permanently added '192.168.0.10' (RSA) to the list of known hosts.\r\nroot@192.168.0.10's password:\r\nLast login: Thu Dec 10 22:04:55 2015 from 192.168.0.1\r\n[root@node2 ~]#<\/pre>\n

\u6b65\u9aa4\u4e8c\uff1a<\/h3>\n

\u4f7f\u7528 ssh-key-gen \u547d\u4ee4\u751f\u6210\u516c\u94a5\u548c\u79c1\u94a5\uff0c\u8fd9\u91cc\u8981\u6ce8\u610f\u7684\u662f\u53ef\u4ee5\u5bf9\u79c1\u94a5\u8fdb\u884c\u52a0\u5bc6\u4fdd\u62a4\u4ee5\u589e\u5f3a\u5b89\u5168\u6027\u3002<\/p>\n

[root@node1 ~]# ssh-keygen\r\nGenerating public\/private rsa key pair.\r\nEnter file in which to save the key (\/root\/.ssh\/id_rsa):\r\nEnter passphrase (empty for no passphrase):\r\nEnter same passphrase again:\r\nYour identification has been saved in \/root\/.ssh\/id_rsa.\r\nYour public key has been saved in \/root\/.ssh\/id_rsa.pub.\r\nThe key fingerprint is:\r\nb4:51:7e:1e:52:61:cd:fb:b2:98:4b:ad:a1:8b:31:6d root@node1.ehowstuff.local\r\nThe key's randomart image is:\r\n+--[ RSA 2048]----+\r\n| . ++ |\r\n| o o o |\r\n| o o o . |\r\n| . o + .. |\r\n| S . . |\r\n| . .. .|\r\n| o E oo.o |\r\n| = ooo. |\r\n| . o.o. |\r\n+-----------------+<\/pre>\n

\u6b65\u9aa4\u4e09\uff1a<\/h3>\n

\u7528 ssh-copy-id \u547d\u4ee4\u5c06\u516c\u94a5\u590d\u5236\u6216\u4e0a\u4f20\u5230\u8fdc\u7a0b\u4e3b\u673a\uff0c\u5e76\u5c06\u8eab\u4efd\u6807\u8bc6\u6587\u4ef6\u8ffd\u52a0\u5230\u8282\u70b92\u7684 ~\/.ssh\/authorized_keys \u4e2d\uff1a<\/p>\n

[root@node1 ~]# ssh-copy-id -i ~\/.ssh\/id_rsa.pub 192.168.0.10\r\nroot@192.168.0.10's password:\r\nNow try logging into the machine, with \"ssh '192.168.0.10'\", and check in:\r\n.ssh\/authorized_keys\r\nto make sure we haven't added extra keys that you weren't expecting.<\/pre>\n

\u6b65\u9aa4\u56db\uff1a<\/h3>\n

\u9a8c\u8bc1\u514d\u5bc6\u7801 SSH \u767b\u5f55\u8282\u70b92\uff1a<\/p>\n

[root@node1 ~]# ssh root@192.168.0.10\r\nLast login: Sun Dec 13 14:03:20 2015 from www.ehowstuff.local<\/pre>\n
\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.tiejiang.org\/4672.html<\/a>\u4f5c\u8005\uff1a\u94c1\u5320<\/span><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/centos-rhel-ssh.html <\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u4f5c\u4e3a\u7cfb\u7edf\u7ba1\u7406\u5458\uff0c\u4f60\u8ba1\u5212\u5728 Linux \u4e0a\u4f7f\u7528 OpenSSH\uff0c\u5b8c\u6210\u65e5\u5e38\u5de5\u4f5c\u7684\u81ea\u52a8\u5316\uff0c\u6bd4\u5982\u6587\u4ef6\u4f20\u8f93\u3001\u5907\u4efd\u6570 […]<\/p>\n","protected":false},"author":63,"featured_media":8753,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-8699","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\/8699","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=8699"}],"version-history":[{"count":20,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/8699\/revisions"}],"predecessor-version":[{"id":249797,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/8699\/revisions\/249797"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/8753"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=8699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=8699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=8699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}