{"id":625,"date":"2020-07-31T23:42:53","date_gmt":"2020-07-31T15:42:53","guid":{"rendered":"https:\/\/www.hncldz.com\/?p=625"},"modified":"2020-08-03T22:21:28","modified_gmt":"2020-08-03T14:21:28","slug":"centos7%e5%8d%87%e7%ba%a7openssh-8-3%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.hncldz.com\/?p=625","title":{"rendered":"CentOS7\u5347\u7ea7OpenSSH \u52308.3\u7248\u672c"},"content":{"rendered":"\n<p>CentOS 7\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\uff0copenssh\u7248\u672c\u662f7.4\uff0c\u5b58\u5728\u4e00\u4e9b\u5b89\u5168\u6f0f\u6d1e\uff0c\u9700\u8981\u5347\u7ea7\u52308.0\u4ee5\u4e0a\u7248\u672c\uff0c\u76ee\u524d\u30102020-7-31\u3011\u6700\u65b0\u7248\u672c\u662f8.3p1\uff0c\u4e0b\u9762\u662f\u5347\u7ea7openssh\u8fc7\u7a0b\uff0c\u6d4b\u8bd5\u8fc7\u7684CentOS\u7248\u672c\u4e3a7.7\u30017.8\uff0c\u6d4b\u8bd5\u8fc7\u7684openssh\u7248\u672c\u67098.2\u30018.3<\/p>\n\n\n\n<p>\u5b89\u88c5\u4e4b\u524d\u9700\u8981\u5148\u5b89\u88c5\u57fa\u672c\u5f00\u53d1\u73af\u5883\uff0c\u53ef\u4ee5\u5728\u7cfb\u7edf\u5b89\u88c5\u65f6\u76f4\u63a5\u52fe\u9009\u201c<strong>\u5f00\u53d1\u5de5\u5177<\/strong>\u201d\u7ec4\u4ef6\uff0c<\/p>\n\n\n\n<p>\u6216\u7528yum\u5b89\u88c5\uff1a yum install gcc make perl<\/p>\n\n\n\n<p><strong>1\u3001\u4e0b\u8f7dopenssh8.3\u5347\u7ea7\u5305\u53ca\u4f9d\u8d56\u7684zlib\u548copenssl\u3002<\/strong><\/p>\n\n\n\n<p>openssh-8.3p1.tar.gz\u3001zlib-1.2.11.tar.gz\u3001openssl-1.1.1g.tar.gz<\/p>\n\n\n\n<p>wget https:\/\/cdn.openbsd.org\/pub\/OpenBSD\/OpenSSH\/portable\/openssh-8.3p1.tar.gz<\/p>\n\n\n\n<p>wget http:\/\/www.zlib.net\/zlib-1.2.11.tar.gz<\/p>\n\n\n\n<p>wget https:\/\/www.openssl.org\/source\/openssl-1.1.1g.tar.gz<\/p>\n\n\n\n<p><strong>2\u3001\u5173\u95edSElinux<\/strong><\/p>\n\n\n\n<p>\u5173\u95edSElinux\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p>setenforce 0<\/p>\n\n\n\n<p>\u4e0a\u9762\u53ea\u662f\u4e34\u65f6\u5173\u95ed\u4e86\uff0c\u91cd\u542f\u540e\u4e0d\u751f\u6548\u3002\u4e0b\u9762\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u4f7f\u6c38\u4e45\u751f\u6548\u3002<\/p>\n\n\n\n<p>vi \/etc\/selinux\/config<\/p>\n\n\n\n<p>\u4fee\u6539\uff1a<\/p>\n\n\n\n<p>SELINUX=disabled<\/p>\n\n\n\n<p>\u4fdd\u5b58\u9000\u51fa<\/p>\n\n\n\n<p><strong>3\u3001\u505c\u6b62ssh\u670d\u52a1<\/strong><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u547d\u4ee4\u5c06\u505c\u6b62\u7cfb\u7edf\u539f\u6709\u7684sshd\u670d\u52a1\uff0c\u8fd9\u5c06\u5bfc\u81f4\u670d\u52a1\u5668\u65e0\u6cd5\u901a\u8fc7ssh\u8fdc\u7a0b\u8fde\u63a5\u3002\u5efa\u8bae\u76f4\u63a5\u64cd\u4f5c\u670d\u52a1\u5668\u8fdb\u884c\u5347\u7ea7openssh\u7684\u8fc7\u7a0b\uff0c\u5982\u679c\u4e0d\u65b9\u4fbf\u76f4\u63a5\u64cd\u4f5c\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u5b89\u88c5\u914d\u7f6etelnet\uff0c\u901a\u8fc7telnet\u8fdc\u7a0b\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u5177\u4f53\u65b9\u6cd5\u672c\u6587\u4e0d\u8d58\u8ff0<\/p>\n\n\n\n<p>systemctl stop sshd<\/p>\n\n\n\n<p><strong>4\u3001\u5378\u8f7d\u539f\u6709\u7684openssh\u5305<\/strong><\/p>\n\n\n\n<p>\u770b\u7cfb\u7edf\u539f\u6709openssh\u5305<\/p>\n\n\n\n<p>rpm -qa | grep openssh<\/p>\n\n\n\n<p>\u6839\u636e\u4e0a\u9762\u67e5\u8be2\u51fa\u7684\u7ed3\u679c\uff0c\u5378\u8f7d\u7cfb\u7edf\u91cc\u539f\u6709Openssh\uff08\u4e00\u822c\u6709\u4e09\u4e2a\u5305\uff0c\u5168\u90e8\u5378\u8f7d\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rpm -e --nodeps ***\uff08***\u66ff\u6362\u4e3a\u4e0a\u9762\u67e5\u8be2\u7684\u7ed3\u679c\uff09<\/pre>\n\n\n\n<p>\u5378\u8f7d\u5b8c\u6210\u540e\u6267\u884crpm -qa | grep openssh\uff0c\u786e\u4fdd\u6ca1\u6709\u56de\u663e<\/p>\n\n\n\n<p><strong>5\u3001\u89e3\u538b\u6e90\u7801\u5305<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar -zxvf zlib-1.2.11.tar.gz<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code><code>tar -zxvf openssh-8.3p1.tar.g<\/code>z<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar -zxvf openssl-1.1.1g.tar.gz<\/code><\/pre>\n\n\n\n<p><strong>6\u3001\u7f16\u8bd1\u5b89\u88c5zlib<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd&nbsp;zlib-1.2.11\n.\/configure&nbsp;--prefix=\/usr\/local\/zlib\nmake&nbsp;&amp;&amp;&nbsp;make&nbsp;install\n\n\u65b0\u5efa\u5e76\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a\nvi \/etc\/ld.so.conf.d\/zlib.conf\n\u52a0\u5165\u5982\u4e0b\u5185\u5bb9\u540e\u4fdd\u5b58\u9000\u51fa\n\/usr\/local\/zlib\/lib\n\u5237\u65b0\u5e93\u6587\u4ef6\uff0c\u52a0\u8f7d\u521a\u624d\u7f16\u8bd1\u5b89\u88c5\u7684zlib\u751f\u6210\u7684\u5e93\u6587\u4ef6\nldconfig -v<\/pre>\n\n\n\n<p><strong>7\u3001\u7f16\u8bd1\u5b89\u88c5openssl<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd&nbsp;openssl-1.1.1g\n.\/config&nbsp;--prefix=\/usr\/local\/ssl&nbsp;-d&nbsp;shared\nmake&nbsp;&amp;&amp;&nbsp;make&nbsp;install\n\u5907\u4efd\u73b0\u6709\u6587\u4ef6\u76ee\u5f55\nmv \/usr\/bin\/openssl \/usr\/bin\/openssl.bak\n\u521b\u5efassl\u76f8\u5173\u8f6f\u8fde\u63a5\nln -s \/usr\/local\/ssl\/bin\/openssl \/usr\/bin\/openssl\nln -s \/usr\/local\/ssl\/include\/openssl \/usr\/include\/openssl\n\u65b0\u5efa\u5e76\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\nvi \/etc\/ld.so.conf.d\/ssl.conf\n\u52a0\u5165\u5982\u4e0b\u5185\u5bb9\u540e\u4fdd\u5b58\u9000\u51fa\n\/usr\/local\/ssl\/lib\n\u5237\u65b0\u5e93\u6587\u4ef6\uff0c\u52a0\u8f7d\u521a\u624d\u7f16\u8bd1\u5b89\u88c5\u7684ssl\u751f\u6210\u7684\u5e93\u6587\u4ef6\nldconfig -v\n\u67e5\u770bopenssl\u7248\u672c\nopenssl version -a<\/pre>\n\n\n\n<p><strong>8\u3001\u7f16\u8bd1\u5b89\u88c5openssh<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd&nbsp;openssh-8.3p1\n.\/configure&nbsp;--prefix=\/usr\/local\/openssh&nbsp;--with-zlib=\/usr\/local\/zlib&nbsp;--with-ssl-dir=\/usr\/local\/ssl\nmake&nbsp;&amp;&amp;&nbsp;make&nbsp;install<\/pre>\n\n\n\n<p>sshd_config\u6587\u4ef6\u4fee\u6539<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo&nbsp;'PermitRootLogin&nbsp;yes'&nbsp;&gt;&gt;\/usr\/local\/openssh\/etc\/sshd_config\necho&nbsp;'PubkeyAuthentication&nbsp;yes'&nbsp;&gt;&gt;\/usr\/local\/openssh\/etc\/sshd_config\necho&nbsp;'PasswordAuthentication&nbsp;yes'&nbsp;&gt;&gt;\/usr\/local\/openssh\/etc\/sshd_config<\/pre>\n\n\n\n<p>\u5907\u4efd\u539f\u6709\u6587\u4ef6\uff0c\u5e76\u5c06\u65b0\u7684\u914d\u7f6e\u590d\u5236\u5230\u6307\u5b9a\u76ee\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mv  \/etc\/ssh \/etc\/ssh.old\nmv&nbsp;\/usr\/sbin\/sshd&nbsp;\/usr\/sbin\/sshd.bak\nmv&nbsp;\/usr\/bin\/ssh&nbsp;\/usr\/bin\/ssh.bak\nmv&nbsp;\/usr\/bin\/ssh-keygen&nbsp;\/usr\/bin\/ssh-keygen.bak\n\u56e0\u4e3a\u4e0a\u9762\u5378\u8f7d\u4e86openssh\uff0c\u4e0a\u9762\u7684\u4e00\u4e9b\u6587\u4ef6\u5df2\u7ecf\u4e0d\u5b58\u5728\u4e86\uff0c\u5982\u679c\u5907\u4efd\u6ca1\u6210\u529f\uff0c\u4e0d\u5fc5\u5728\u610f\nmkdir \/etc\/ssh\ncp&nbsp;\/usr\/local\/openssh\/etc\/sshd_config&nbsp;\/etc\/ssh\/sshd_config\ncp&nbsp;\/usr\/local\/openssh\/etc\/ssh_host_ecdsa_key.pub&nbsp;\/etc\/ssh\/ssh_host_ecdsa_key.pub\ncp&nbsp;\/usr\/local\/openssh\/bin\/ssh&nbsp;\/usr\/bin\/ssh\ncp&nbsp;\/usr\/local\/openssh\/sbin\/sshd&nbsp;\/usr\/sbin\/sshd\ncp&nbsp;\/usr\/local\/openssh\/bin\/ssh-keygen&nbsp;\/usr\/bin\/ssh-keygen\n<\/pre>\n\n\n\n<p>8\u3001<strong>\u914d\u7f6esshd\u670d\u52a1\u5f00\u673a\u542f\u52a8<\/strong><\/p>\n\n\n\n<p><strong>\u6ce8\u610f\u5566\uff01\u6ce8\u610f\u5566\uff01<\/strong>\u4f7f\u7528\u9ed8\u8ba4\u7684\u6e90\u7801\u5b89\u88c5\u7684openssh\uff0c\u5728\u4f7f\u7528systemd\u7ba1\u7406sshd\u670d\u52a1\u65f6\uff0c\u4f60\u4f1a\u53d1\u73b0\uff0c\u542f\u52a8\u547d\u4ee4\u4f1a\u5361\u4f4f\uff0c\u7a0d\u540e\u7528systemctl \u67e5\u770bstatus\u65f6\u53d1\u73b0\u5361\u5728\u6b63\u5728\u542f\u52a8\uff08activating\uff09\u7684\u9636\u6bb5<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.hncldz.com\/wp-content\/uploads\/2020\/08\/28813320_1530528510F7gQ.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"150\" data-original=\"https:\/\/www.hncldz.com\/wp-content\/uploads\/2020\/08\/28813320_1530528510F7gQ.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-638\"  sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/div><\/figure>\n\n\n\n<p>\u6b64\u65f6\u867d\u7136\u53ef\u4ee5\u901a\u8fc7ssh\u8fde\u63a5\u6b64\u670d\u52a1\u5668\uff0c\u4f46\u5982\u679c\u67e5\u770b\u7cfb\u7edf\u65e5\u5fd7\uff0c\u4f1a\u53d1\u73b0sshd\u670d\u52a1\u5728\u4e0d\u65ad\u5c1d\u8bd5\u91cd\u65b0\u542f\u52a8\u3002<\/p>\n\n\n\n<p>\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\u7684\u539f\u56e0\u662fopenssh\u7684\u6e90\u7801\u9ed8\u8ba4\u5e76\u6ca1\u6709\u4e0esystemd\u8fdb\u884c\u96c6\u6210\u548c\u9002\u914d\uff0csshd\u5728\u542f\u52a8\u5b8c\u6210\u540e\uff0c\u6ca1\u6709\u7ed9systemd\u53d1\u6d88\u606f\uff0csystemd\u5c31\u4e00\u76f4\u5728\u90a3\u50bb\u7b49\uff0c\u7b49\u8fc7\u4e86\u8d85\u65f6\u65f6\u95f4\u5c31\u5c1d\u8bd5\u91cd\u65b0\u542f\u52a8sshd\u3002\u89e3\u51b3\u6b64\u95ee\u9898\u7684\u65b9\u6cd5\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u4fee\u6539openssh\u7684\u6e90\u4ee3\u7801\uff0c\u4e0esystemd\u9002\u914d\uff0c\u53ef\u53c2\u8003<a href=\"http:\/\/blog.chinaunix.net\/uid-28813320-id-5786956.html\">http:\/\/blog.chinaunix.net\/uid-28813320-id-5786956.html<\/a>\uff0c\u672c\u4eba\u672a\u5c1d\u8bd5\u6b64\u65b9\u6cd5\uff0c\u6709\u5174\u8da3\u7684\u53ef\u4ee5\u5c1d\u8bd5\u770b\u770b\u3002\u53e6\u4e00\u79cd\u65b9\u5f0f\u5c31\u662f\u4ee5\u65e7\u7684sysv\u65b9\u5f0f\u542f\u52a8sshd\u670d\u52a1\uff0c\u5177\u4f53\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd openssh-8.3p1<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">cp -p contrib\/redhat\/sshd.init \/etc\/init.d\/sshd<br>chmod +x \/etc\/init.d\/sshd<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">chkconfig <strong>--<\/strong>add sshd<br>chkconfig sshd on<br>service&nbsp;sshd&nbsp;restart<\/pre>\n\n\n\n<p>\u67e5\u770bsshd\u670d\u52a1\u72b6\u6001<\/p>\n\n\n\n<p>systemctl status sshd<\/p>\n\n\n\n<p>\u67e5\u770bopenssh\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh&nbsp;-V<\/pre>\n\n\n\n<p>\u5982\u679c\u6b63\u5e38\uff0c\u5c31\u91cd\u542f\u670d\u52a1\u5668\u518d\u67e5\u770b\u4e00\u4e0b\uff0c\u786e\u8ba4sshd\u670d\u52a1\u80fd\u5426\u6b63\u5e38\u5f00\u673a\u542f\u52a8 <\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS 7\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\uff0copenssh\u7248\u672c\u662f7.4\uff0c\u5b58\u5728\u4e00\u4e9b\u5b89\u5168\u6f0f\u6d1e\uff0c\u9700\u8981\u5347\u7ea7\u52308.0\u4ee5\u4e0a\u7248\u672c\uff0c\u76ee\u524d\u30102 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-625","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts\/625","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=625"}],"version-history":[{"count":17,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts\/625\/revisions"}],"predecessor-version":[{"id":650,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts\/625\/revisions\/650"}],"wp:attachment":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=625"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=625"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=625"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}