{"id":2777,"date":"2017-10-16T10:28:43","date_gmt":"2017-10-16T02:28:43","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=2777"},"modified":"2017-10-16T10:28:43","modified_gmt":"2017-10-16T02:28:43","slug":"%e8%a7%a3%e5%86%b3centos7%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%94%a8ssh%e8%bf%9e%e6%8e%a5%e8%80%81%e6%98%af%e8%87%aa%e5%8a%a8%e6%96%ad%e5%bc%80%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/hemanual\/%e8%a7%a3%e5%86%b3centos7%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%94%a8ssh%e8%bf%9e%e6%8e%a5%e8%80%81%e6%98%af%e8%87%aa%e5%8a%a8%e6%96%ad%e5%bc%80%e9%97%ae%e9%a2%98\/","title":{"rendered":"\u89e3\u51b3centos7\u670d\u52a1\u5668\u7528ssh\u8fde\u63a5\u8001\u662f\u81ea\u52a8\u65ad\u5f00\u95ee\u9898"},"content":{"rendered":"<p>\u6700\u8fd1\u81ea\u5df1\u4e70\u4e86\u4e2a\u670d\u52a1\u5668\uff0c\u7528ssh\u8fde\u63a5\u65f6\u4e00\u6bb5\u65f6\u95f4\u4e0d\u64cd\u4f5c\u5c31\u8981\u91cd\u65b0\u8fde\u63a5\uff0c\u8ba9\u4eba\u5f88\u662f\u9ebb\u70e6\u3002\u73b0\u5728\u7ec8\u4e8e\u89e3\u51b3\u4e86\uff0c\u6b65\u9aa4\u5f88\u7b80\u5355\u3002<br \/>\n\u767b\u9646\u670d\u52a1\u5668\u540e\u8f93\u5165 lsb_release -a \u53ef\u4ee5\u67e5\u770b\u7cfb\u7edf\u7248\u672c\uff0c\u6b64\u547d\u4ee4\u9002\u7528\u4e8e\u6240 \u6709\u7684linux\uff0c\u5305\u62ecRedhat\u3001SuSE\u3001Debian\u7b49\u53d1\u884c\u7248\uff0c\u4f46\u662f\u5728debian\u4e0b\u8981\u5b89\u88c5lsb\u3002\u5982\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs ruby has-numbering\">[root<span class=\"hljs-variable\">@chen<\/span> \/]<span class=\"hljs-comment\"># lsb_release -a<\/span>\r\n<span class=\"hljs-constant\">LSB<\/span> <span class=\"hljs-constant\">Version<\/span><span class=\"hljs-symbol\">:<\/span>    <span class=\"hljs-symbol\">:core-<\/span><span class=\"hljs-number\">4.1<\/span>-<span class=\"hljs-symbol\">amd64:<\/span>core-<span class=\"hljs-number\">4.1<\/span>-noarch\r\n<span class=\"hljs-constant\">Distributor<\/span> <span class=\"hljs-constant\">ID<\/span><span class=\"hljs-symbol\">:<\/span> <span class=\"hljs-constant\">CentOS<\/span>\r\n<span class=\"hljs-constant\">Description<\/span><span class=\"hljs-symbol\">:<\/span>    <span class=\"hljs-constant\">CentOS<\/span> <span class=\"hljs-constant\">Linux<\/span> release <span class=\"hljs-number\">7.3<\/span>.<span class=\"hljs-number\">1611<\/span> (<span class=\"hljs-constant\">Core<\/span>) \r\n<span class=\"hljs-constant\">Release<\/span><span class=\"hljs-symbol\">:<\/span>        <span class=\"hljs-number\">7.3<\/span>.<span class=\"hljs-number\">1611<\/span>\r\n<span class=\"hljs-constant\">Codename<\/span><span class=\"hljs-symbol\">:<\/span>       <span class=\"hljs-constant\">Core<\/span><\/code><\/pre>\n<p>\u6b64\u65b9\u6cd5\u9002\u7528\u4e8ecentos7\u7684\u7248\u672c\u3002\u7528\u6587\u672c\u7f16\u8bd1\u5668\u6253\u5f00ssh\u670d\u52a1\u91cc\u9762\u7684\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u3002\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs vhdl has-numbering\">[root@chen \/]# vi \/etc\/ssh\/sshd_config \r\n#       $OpenBSD: sshd_config,v <span class=\"hljs-number\">1.93<\/span> <span class=\"hljs-number\">2014<\/span>\/<span class=\"hljs-number\">01<\/span>\/<span class=\"hljs-number\">10<\/span> <span class=\"hljs-number\">05<\/span>:<span class=\"hljs-number\">59<\/span>:<span class=\"hljs-number\">19<\/span> djm Exp $\r\n\r\n# This <span class=\"hljs-keyword\">is<\/span> the sshd server system-wide <span class=\"hljs-keyword\">configuration<\/span> <span class=\"hljs-keyword\">file<\/span>.  See\r\n# sshd_config(<span class=\"hljs-number\">5<\/span>) <span class=\"hljs-keyword\">for<\/span> more information.\r\n\r\n# This sshd was compiled <span class=\"hljs-keyword\">with<\/span> PATH=\/usr\/local\/bin:\/usr\/bin\r\n\r\n# The strategy used <span class=\"hljs-keyword\">for<\/span> options <span class=\"hljs-keyword\">in<\/span> the <span class=\"hljs-keyword\">default<\/span> sshd_config shipped <span class=\"hljs-keyword\">with<\/span>\r\n# OpenSSH <span class=\"hljs-keyword\">is<\/span> <span class=\"hljs-keyword\">to<\/span> specify options <span class=\"hljs-keyword\">with<\/span> their <span class=\"hljs-keyword\">default<\/span> value where<\/code><\/pre>\n<p>\u6b64\u65f6\u5df2\u7ecf\u8fdb\u5165\u914d\u7f6e\u6587\u4ef6\u91cc\u9762\u4e86\uff0c\u8f93\u5165 i \u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u627e\u5230\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs vala has-numbering\"><span class=\"hljs-preprocessor\">#PermitUserEnvironment no#Compression delayed<\/span>\r\n<span class=\"hljs-preprocessor\">#ClientAliveInterval 0<\/span>\r\n<span class=\"hljs-preprocessor\">#ClientAliveCountMax3<\/span>\r\n<span class=\"hljs-preprocessor\">#ShowPatchLevel no<\/span>\r\n<span class=\"hljs-preprocessor\">#PidFile \/var\/run\/sshd.pid<\/span>\r\n<span class=\"hljs-preprocessor\">#MaxStartups 10:30:100<\/span>\r\n<span class=\"hljs-preprocessor\">#PermitTunnel no<\/span>\r\n<span class=\"hljs-preprocessor\">#ChrootDirectory none<\/span>\r\n<span class=\"hljs-preprocessor\">#VersionAddendum none<\/span><\/code><\/pre>\n<p>\u5c06<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs vala has-numbering\"><span class=\"hljs-preprocessor\">#ClientAliveInterval 0<\/span>\r\n<span class=\"hljs-preprocessor\">#ClientAliveCountMax3<\/span><\/code><\/pre>\n<p>\u53bb\u6389\u6ce8\u91ca\u5e76\u6539\u4e3a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs  has-numbering\">ClientAliveInterval 60\r\nClientAliveCountMax 3<\/code><\/pre>\n<p>ClientAliveInterval\u6307\u5b9a\u4e86\u670d\u52a1\u5668\u7aef\u5411\u5ba2\u6237\u7aef\u8bf7\u6c42\u6d88\u606f \u7684\u65f6\u95f4\u95f4\u9694\uff0c \u9ed8\u8ba4\u662f0, \u4e0d\u53d1\u9001.\u800cClientAliveInterval 60\u8868\u793a\u6bcf\u5206\u949f\u53d1\u9001\u4e00\u6b21, \u7136\u540e\u5ba2\u6237\u7aef\u54cd\u5e94, \u8fd9\u6837\u5c31\u4fdd\u6301\u957f\u8fde\u63a5\u4e86.ClientAliveCountMax, \u4f7f\u7528\u9ed8\u8ba4\u503c3\u5373\u53ef.ClientAliveCountMax\u8868\u793a\u670d\u52a1\u5668\u53d1\u51fa\u8bf7\u6c42\u540e\u5ba2\u6237\u7aef\u6ca1\u6709\u54cd\u5e94\u7684\u6b21\u6570\u8fbe\u5230\u4e00\u5b9a\u503c, \u5c31\u81ea\u52a8\u65ad\u5f00. \u6b63\u5e38\u60c5\u51b5\u4e0b, \u5ba2\u6237\u7aef\u4e0d\u4f1a\u4e0d\u54cd\u5e94\u3002\u00a0 \u6700\u540e\u4e00\u5b9a\u8981\u8bb0\u5f97\u91cd\u542fssh\u670d\u52a1\uff0c\u5426\u5219\u662f\u4e0d\u4f1a\u751f\u6548\u7684\uff0c\u91cd\u542f\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs ruby has-numbering\">[root<span class=\"hljs-variable\">@chen<\/span> \/]<span class=\"hljs-comment\"># systemctl restart sshd.service<\/span>\r\n[root<span class=\"hljs-variable\">@chen<\/span> \/]<span class=\"hljs-comment\"># <\/span><\/code><\/pre>\n<p>\u7136\u540e\u5c31OK\u5566\u3002\u53e6\u5916\u6084\u6084\u544a\u8bc9\u4f60\u5224\u65adssh\u670d\u52a1\u6709\u6ca1\u6709\u542f\u52a8\u7684\u547d\u4ee4\u662f\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs avrasm has-numbering\">[root@chen \/]<span class=\"hljs-preprocessor\"># systemctl status  sshd.service<\/span>\r\n?sshd<span class=\"hljs-preprocessor\">.service<\/span> - OpenSSH server daemon\r\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/sshd<span class=\"hljs-preprocessor\">.service<\/span><span class=\"hljs-comment\">; enabled; vendor preset: enabled)<\/span>\r\n   Active: active (running) since Thu <span class=\"hljs-number\">2017<\/span>-<span class=\"hljs-number\">09<\/span>-<span class=\"hljs-number\">21<\/span> <span class=\"hljs-number\">16<\/span>:<span class=\"hljs-number\">57<\/span>:<span class=\"hljs-number\">34<\/span> CST<span class=\"hljs-comment\">; 2min 35s ago<\/span>\r\n     Docs: man:sshd(<span class=\"hljs-number\">8<\/span>)\r\n           man:sshd_config(<span class=\"hljs-number\">5<\/span>)\r\n Main PID: <span class=\"hljs-number\">9640<\/span> (sshd)\r\n   CGroup: \/system<span class=\"hljs-preprocessor\">.slice<\/span>\/sshd<span class=\"hljs-preprocessor\">.service<\/span>\r\n           \u5fd6<span class=\"hljs-number\">9640<\/span> \/usr\/sbin\/sshd -D<\/code><\/pre>\n<p>\u770b\u5230running\u5c31\u662f\u542f\u52a8\u4e86\uff0c\u5982\u679c\u6ca1\u6709\u542f\u52a8\u7684\u8bdd\u8f93\u5165<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs sql has-numbering\">systemctl <span class=\"hljs-operator\"><span class=\"hljs-keyword\">start<\/span> sshd.service<\/span><\/code><\/pre>\n<p>\u5c31\u542f\u52a8\u5b8c\u6210\u4e86\u3002\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8\u7684\u8bdd\u5219\u8f93\u5165\uff1a<\/p>\n<pre class=\"prettyprint\"><code class=\"hljs avrasm has-numbering\">systemctl enable sshd<span class=\"hljs-preprocessor\">.service<\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u81ea\u5df1\u4e70\u4e86\u4e2a\u670d\u52a1\u5668\uff0c\u7528ssh\u8fde\u63a5\u65f6\u4e00\u6bb5\u65f6\u95f4\u4e0d\u64cd\u4f5c\u5c31\u8981\u91cd\u65b0\u8fde\u63a5\uff0c\u8ba9\u4eba\u5f88\u662f\u9ebb\u70e6\u3002\u73b0\u5728\u7ec8\u4e8e\u89e3\u51b3\u4e86\uff0c\u6b65\u9aa4\u5f88\u7b80\u5355\u3002 \u767b &#8230; <a title=\"\u89e3\u51b3centos7\u670d\u52a1\u5668\u7528ssh\u8fde\u63a5\u8001\u662f\u81ea\u52a8\u65ad\u5f00\u95ee\u9898\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/hemanual\/%e8%a7%a3%e5%86%b3centos7%e6%9c%8d%e5%8a%a1%e5%99%a8%e7%94%a8ssh%e8%bf%9e%e6%8e%a5%e8%80%81%e6%98%af%e8%87%aa%e5%8a%a8%e6%96%ad%e5%bc%80%e9%97%ae%e9%a2%98\/\" aria-label=\"\u9605\u8bfb \u89e3\u51b3centos7\u670d\u52a1\u5668\u7528ssh\u8fde\u63a5\u8001\u662f\u81ea\u52a8\u65ad\u5f00\u95ee\u9898\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3,49,5],"tags":[495,75],"class_list":["post-2777","post","type-post","status-publish","format-standard","hentry","category-hemanual","category-linux","category-jishu","tag-centos7-x","tag-ssh"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/2777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=2777"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/2777\/revisions"}],"predecessor-version":[{"id":2778,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/2777\/revisions\/2778"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=2777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=2777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=2777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}