{"id":244,"date":"2018-04-09T23:48:05","date_gmt":"2018-04-09T15:48:05","guid":{"rendered":"https:\/\/jpeng.xyz\/?p=244"},"modified":"2025-07-12T19:58:00","modified_gmt":"2025-07-12T11:58:00","slug":"ssh%e8%bf%9e%e6%8e%a5%e5%a4%b1%e8%b4%a5%e7%9a%84%e7%9b%b8%e5%85%b3%e6%8e%92%e9%94%99","status":"publish","type":"post","link":"https:\/\/jpeng.xyz\/?p=244","title":{"rendered":"SSH\u8fde\u63a5\u5931\u8d25\u7684\u76f8\u5173\u6392\u9519"},"content":{"rendered":"<p>\u5148\u7528ping\u547d\u4ee4\u6392\u67e5\u662f\u5426\u80fd\u591fPing\u901a<\/p>\n<h5>\u4f7f\u7528ssh -v\u547d\u4ee4<\/h5>\n<p>\u7528ssh -v\u53bb\u8fde\u6709\u95ee\u9898\u7684\u670d\u52a1\u5668\uff0c\u4f1a\u6709\u6bd4\u8f83\u8be6\u7ec6\u7684\u8c03\u8bd5\u4fe1\u606f\u5728\u5c4f\u5e55\u4e0a\u8f93\u51fa\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5224\u65ad\u662f\u54ea\u4e00\u6b65\u51fa\u4e86\u95ee\u9898\u3002<\/p>\n<p>\u4e3b\u8981\u662f\u770b\u662f\u5ba2\u6237\u7aef\u8fd8\u662f\u670d\u52a1\u5668\u7684\u95ee\u9898\u3002\u5982\u679c\u662f\u5ba2\u6237\u7aef\u7684\u95ee\u9898\uff0c\u5e94\u8be5log\u4e2d\u6709\u5199\u3002\u5982\u679c\u662f\u6ca1\u6709\u4ec0\u4e48\u6709\u7528\u4fe1\u606f\uff0c\u5c31\u53ef\u80fd\u662f\u670d\u52a1\u5668\u7aef\u51fa\u95ee\u9898\u4e86\u3002<\/p>\n<pre><code class=\"line-numbers\">[root@jpeng ~]# ssh -v root@123.207.4.225\nOpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013\ndebug1: Reading configuration data \/etc\/ssh\/ssh_config\ndebug1: \/etc\/ssh\/ssh_config line 56: Applying options for *\ndebug1: Connecting to 10.1.101.35 [10.1.101.35] port 22.\ndebug1: Connection established.\ndebug1: permanently_set_uid: 0\/0\ndebug1: identity file \/root\/.ssh\/id_rsa type -1\ndebug1: identity file \/root\/.ssh\/id_rsa-cert type -1\ndebug1: identity file \/root\/.ssh\/id_dsa type -1\ndebug1: identity file \/root\/.ssh\/id_dsa-cert type -1\ndebug1: identity file \/root\/.ssh\/id_ecdsa type -1\ndebug1: identity file \/root\/.ssh\/id_ecdsa-cert type -1\ndebug1: identity file \/root\/.ssh\/id_ed25519 type -1\ndebug1: identity file \/root\/.ssh\/id_ed25519-cert type -1\ndebug1: Enabling compatibility mode for protocol 2.0\ndebug1: Local version string SSH-2.0-OpenSSH_6.6.1\nssh_exchange_identification: read: Connection reset by peer\n<\/code><\/pre>\n<p>\u73b0\u5728\u770b\u8d77\u6765\u662f\u670d\u52a1\u5668\u51fa\u95ee\u9898\u4e86\uff0c\u867d\u7136\u4e0d\u80fdssh\u5230\u670d\u52a1\u5668\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u552e\u540e\u5de5\u5177\u91ccVNC\u8fdb\u53bb\u3002<\/p>\n<h4>\u6392\u9519\u601d\u8def1\uff1a<\/h4>\n<p>\u68c0\u67e5 \/etc\/hosts.deny \u91cc\u9762\u662f\u5426\u6709 SSHD\uff1a \u5f00\u5934\u7684\u884c\uff0c\u6709\u6b64\u884c\u8868\u793aSSH\u7684\u5ba2\u6237\u7aefIP\u8fdb\u5165\u4e86\u9ed1\u540d\u5355\uff0c\u5c06\u5176\u6ce8\u91ca\uff1b<br \/>\n\u518d\u68c0\u67e5\/etc\/hosts.allow \u91cc\u9762\u662f\u5426\u4e5f\u6709 SSHD\uff1a\u5f00\u5934\u7684\u884c\uff0c\u5982\u679c\u662f\/etc\/hosts.deny\u6ca1\u6709 SSHD\u76f8\u5173\u5185\u5bb9\u800c\/etc\/hosts.allow\u91cc\u6709SSHD\u76f8\u5173\u5185\u5bb9\uff0c\u8fd9\u5c31\u6210\u4e86\u767d\u540d\u5355\uff0c\u53ea\u6709\u5728\u8fd9\u4e2a\u6587\u4ef6\u91cc\u9762\u7684IP\u624d\u80fd\u901a\u8fc7SSH\u8fde\u63a5\uff0c\u4e5f\u53ef\u4ee5\u5148\u6ce8\u91ca<\/p>\n<h4>\u6392\u9519\u601d\u8def2\uff1a<\/h4>\n<p>\u68c0\u67e5\/etc\/ssh \u76ee\u5f55\u4e0b\u76f8\u5173\u6587\u4ef6\u7684\u6743\u9650<br \/>\n\u6709\u78b0\u5230\u8fc7\u5f88\u591a\u4f8b\u662f\u8fd9\u79cd\u60c5\u51b5\uff0c\u5ba2\u6237\u7684SSHD\u670d\u52a1\u76f8\u5173key\u6587\u4ef6\u6743\u9650\u88ab\u4fee\u6539\uff0c\u5bfc\u81f4SSHD\u670d\u52a1\u542f\u52a8\u5f02\u5e38\u3002<br \/>\n\u5148\u6267\u884c ls -l \/etc\/ssh\/*key \u67e5\u770b\u4e00\u4e0b\u76f8\u5173\u6587\u4ef6\u6743\u9650\u662f\u5426\u6709\u95ee\u9898<br \/>\n\u6267\u884c<code>systemctl restart sshd<\/code>\u67e5\u770b\u80fd\u5426\u6b63\u5e38\uff0c\u5373\u4f7f\u670d\u52a1\u91cd\u542f\u6ca1\u6709\u5931\u8d25\uff0cssh\u5ba2\u6237\u7aef\u73b0\u5728\u4e5f\u662f\u65e0\u6cd5\u8fde\u63a5\u7684<br \/>\n\u518d\u6267\u884c<code>systemctl ststus sshd -l<\/code>\u67e5\u770b\u4e00\u4e0b\u670d\u52a1\u72b6\u6001<\/p>\n<p>\u4e00\u822c\u6765\u8bb2\uff0c\u8fd9\u4e9b\u76f8\u5173\u6587\u4ef6\u4e0d\u9700\u8981\u6267\u884c\u6743\u9650\uff0c\u800c\u4e14\u4e5f\u53ea\u6709root\u7528\u6237\u53ef\u4ee5\u8bbf\u95ee\uff0c\u56e0\u6b64\u6b63\u5e38\u91cd\u65b0\u8d4b\u4e88\u8fd9\u4e9b\u6587\u4ef6 600 \u6216\u8005 640 \u6743\u9650\u5373\u53ef\u3002<br \/>\n\u7136\u540e\u518d\u91cd\u542f\u4e00\u4e0b\u670d\u52a1<\/p>\n<pre><code class=\"line-numbers\">chmod 640 \/etc\/ssh\/*key \nsystemctl restart sshd \nsystemctl status sshd -l\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u7528ping\u547d\u4ee4\u6392\u67e5\u662f\u5426\u80fd\u591fPing\u901a \u4f7f\u7528ssh -v\u547d\u4ee4&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[13,14],"class_list":["post-244","post","type-post","status-publish","format-standard","hentry","category-2","tag-linux","tag-ssh"],"_links":{"self":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=244"}],"version-history":[{"count":2,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":246,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions\/246"}],"wp:attachment":[{"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jpeng.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}