{"id":743,"date":"2022-04-09T11:49:01","date_gmt":"2022-04-09T03:49:01","guid":{"rendered":"https:\/\/log.tanxiaodian.com\/?p=743"},"modified":"2022-04-09T11:55:16","modified_gmt":"2022-04-09T03:55:16","slug":"docker%e4%b8%adcentos%e5%ae%b9%e5%99%a8%e5%bc%80%e5%90%afssh%e6%9c%8d%e5%8a%a1%e8%bf%9c%e7%a8%8b%e8%bf%9e%e6%8e%a5","status":"publish","type":"post","link":"https:\/\/log.tanxiaodian.com\/?p=743","title":{"rendered":"docker\u4e2dcentos\u5bb9\u5668\u5f00\u542fssh\u670d\u52a1\u8fdc\u7a0b\u8fde\u63a5"},"content":{"rendered":"\n<p>\u8fd9\u91cc\u4f7f\u7528\u7684\u5bb9\u5668\u662fcentos7\u73af\u5883\uff0c\u57fa\u672c\u662f\u4e2a\u6bd4\u8f83\u7eaf\u51c0\u7684\u73af\u5883\uff0c\u51e0\u4e4e\u4ec0\u4e48\u90fd\u6ca1\u88c5<br>\u6839\u636e\u81ea\u5df1\u9700\u6c42\uff0c\u5148\u5b89\u88c5\u4e00\u4e9b\u57fa\u672c\u7684\uff08\u5bb9\u5668\uff0c\u9ed8\u8ba4\u662froot\u7528\u6237\uff09<\/p>\n\n\n\n<p>yum install -y net-tools<br> <br>\u63a5\u7740\u5b89\u88c5openssl\uff0copenssh-server<\/p>\n\n\n\n<p>yum install -y openssl openssh-server<br> <br>\u7136\u540e\u542f\u52a8ssh<\/p>\n\n\n\n<p>\/usr\/sbin\/sshd -D &amp;<br> <br>\u8fd9\u91cc\u4f1a\u62a5\u9519<\/p>\n\n\n\n<p>[root@68e7598797d7 \/]# \/usr\/sbin\/sshd -D &amp;<br>Could not load host key: \/etc\/ssh\/ssh_host_rsa_key<br>Could not load host key: \/etc\/ssh\/ssh_host_ecdsa_key<br>Could not load host key: \/etc\/ssh\/ssh_host_ed25519_key<br> <br>\u9700\u8981\u8fdb\u884c\u4e0b\u9762\u7684\u8bbe\u7f6e<\/p>\n\n\n\n<p>[root@68e7598797d7 \/]# ssh-keygen -q -t rsa -b 2048 -f \/etc\/ssh\/ssh_host_rsa_key -N &#8221;<br>[root@68e7598797d7 \/]# ssh-keygen -q -t ecdsa -f \/etc\/ssh\/ssh_host_ecdsa_key -N &#8221;<br>[root@68e7598797d7 \/]# ssh-keygen -t dsa -f \/etc\/ssh\/ssh_host_ed25519_key -N &#8221;<br> <br>\u63a5\u7740\u4fee\u6539sshd_config\u6587\u4ef6\u914d\u7f6e\u4fe1\u606f\uff0c\u8def\u5f84\u4e3a \/etc\/ssh\/sshd_config<\/p>\n\n\n\n<p>1.\u5c06 Port 22 \u524d\u9762\u7684\u6ce8\u91ca\u53bb\u6389\uff08\u5f00\u542f22\u53f7\u7aef\u53e3\uff09<\/p>\n\n\n\n<p>2.\u5c06 PermitRootLogin \u7684 no \u6539\u4e3a yes \uff08\u8fd9\u91cc\u662f\u8bbe\u7f6e\u662f\u5426\u5141\u8bb8root\u7528\u6237\u767b\u5f55\uff0c\u53ef\u6839\u636e\u81ea\u5df1\u9700\u6c42\u51b3\u5b9a\u662f\u5426\u5f00\u542f\uff09<\/p>\n\n\n\n<p>\u91cd\u65b0\u542f\u52a8ssh<\/p>\n\n\n\n<p>[root@68e7598797d7 \/]# \/usr\/sbin\/sshd -D &amp;<br> <br>\u6ce8\u610f\uff0c\u5982\u679c\u8bbe\u7f6e\u90fd\u6ca1\u95ee\u9898\u7684\u8bdd\uff0c\u547d\u4ee4\u7ed3\u5c3e\u52a0\u4e2a\u2018&amp;\u2019\uff0c\u81ea\u52a8\u540e\u53f0\u8fd0\u884c\uff0c\u542f\u52a8\u6210\u529f\u4f1a\u8fd4\u56de\u8fdb\u7a0b\u53f7<\/p>\n\n\n\n<p>[root@68e7598797d7 \/]# \/usr\/sbin\/sshd -D &amp;<br>[1] 16<br> <br>\u7ed9root\u6dfb\u52a0\u5bc6\u7801<br>\u6dfb\u52a0\u8fc7\u7684\u53ef\u8df3\u8fc7\u6b64\u6b65\u9aa4<\/p>\n\n\n\n<p>[root@68e7598797d7 \/]# yum install passwd<br>[root@68e7598797d7 \/]# passwd<br> <br>\u5c06\u5f53\u524d\u5bb9\u5668\u4fdd\u5b58\u6210\u65b0\u7684\u955c\u50cf<br>\u5148\u9000\u51fa\u5e76\u5173\u95ed\u521a\u624d\u7684\u5bb9\u5668\uff0c\u53ef\u4ee5\u4f7f\u7528 exit \u547d\u4ee4\uff0c\u7136\u540e\u4fdd\u5b58\u955c\u50cf<\/p>\n\n\n\n<p>docker commit mycontainer newimage<br> <br>\u2018mycontainer\u2019 \u4e3a\u521a\u624d\u4f7f\u7528\u7684\u5bb9\u5668\uff0c&#8217;newimage\u2019\u4e3a\u65b0\u7684\u955c\u50cf\u540d\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u6539\u52a8<\/p>\n\n\n\n<p>\u57fa\u4e8e\u65b0\u955c\u50cf\u91cd\u65b0\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668<\/p>\n\n\n\n<p>docker run -itd &#8211;name newcont -p 8000:22 newimage<br> <br>\u547d\u4ee4\u4e2d\u7684\u7aef\u53e3\u53f7\u53ef\u4ee5\u6307\u5b9a\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5927\u5199P\u81ea\u52a8\u6620\u5c04\uff08\u5efa\u8bae\u81ea\u5df1\u6307\u5b9a\uff09<\/p>\n\n\n\n<p>\u6ce8\u610f\u5fc5\u987b\uff1a\u8fdb\u5165\u5bb9\u5668\u5e76\u91cd\u65b0\u5f00\u542fssh\uff0c\u4e0d\u4f1a\u81ea\u52a8\u542f\u52a8<\/p>\n\n\n\n<p>[root@68e7598797d7 \/]# \/usr\/sbin\/sshd -D &amp;<br>[1] 15<br> <br>\u63a5\u7740\u5c31\u53ef\u4ee5 \u4f7f\u7528xshell\u8fdc\u7a0b\u8fde\u63a5<\/p>\n\n\n\n<p>\u542f\u52a8\u5b8c\u6210\u540e\u5c31\u53ef\u4ee5\u901a\u8fc7xshell\u6216\u8005\u5176\u4ed6\u8fde\u63a5\u5de5\u5177\u8fdb\u884c\u8fdc\u7a0b\u8fde\u63a5\u4e86\uff0c\u8bb0\u4f4f\uff0cip\u662f\u5bbf\u4e3b\u673a\u7684IP\u5730\u5740\uff0c\u7aef\u53e3\u53f7\u5bbf\u4e3b\u673a\u4e0a\u7684\u7aef\u53e3\uff0c\u5373\u4e0a\u9762\u7aef\u53e3\u6620\u5c04\u547d\u4ee4\u4e2d\u7684 8000 \uff01<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>\u5b89\u88c5 openssl \u548c openssl-server\u670d\u52a1==\u300b\u542f\u52a8 \/usr\/sbin\/sshd -D ===\u300b\u4fee\u6539\u4e86 \/etc\/ssh\/sshd_config \u914d\u7f6e===\u300b\u8bbe\u7f6eroot\u7684ssh\u5bc6\u7801 yum install passwd        passwd  ===\u300b\u505c\u6b62\u5f53\u524d\u955c\u50cf===\u300b \u63d0\u4ea4\u521a\u624d\u7684\u5bb9\u5668docker commit mycontainer newimage \u5230\u955c\u50cf===\u300b\u4ece\u65b0\u8fd0\u884c\u8fd9\u4e2a\u65b0\u955c\u50cf docker run -itd &#8211;name newcont -p 8000:22 newimage \u5e76\u6620\u5c04\u7aef\u53e3===\u300b\u8fdb\u5165\u5bb9\u5668\u5e76\u5f00\u542fssh\u670d\u52a1 \/usr\/sbin\/sshd -D &amp; <\/strong><\/p>\n\n\n\n<p>\u539f\u6587\u5730\u5740<br>docker\u4e2dcentos\u5bb9\u5668\u5f00\u542fssh\u670d\u52a1\u8fdc\u7a0b\u8fde\u63a5<br>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<br>\u7248\u6743\u58f0\u660e\uff1a\u672c\u6587\u4e3aCSDN\u535a\u4e3b\u300c\u7406\u6728\u5ba2\u300d\u7684\u539f\u521b\u6587\u7ae0\uff0c\u9075\u5faaCC 4.0 BY-SA\u7248\u6743\u534f\u8bae\uff0c\u8f6c\u8f7d\u8bf7\u9644\u4e0a\u539f\u6587\u51fa\u5904\u94fe\u63a5\u53ca\u672c\u58f0\u660e\u3002<br>\u539f\u6587\u94fe\u63a5\uff1ahttps:\/\/blog.csdn.net\/qq_41941875\/article\/details\/102308213<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u91cc\u4f7f\u7528\u7684\u5bb9\u5668\u662fcentos7\u73af\u5883\uff0c\u57fa\u672c\u662f\u4e2a\u6bd4\u8f83\u7eaf&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/log.tanxiaodian.com\/?p=743\">Continue reading<span class=\"screen-reader-text\">docker\u4e2dcentos\u5bb9\u5668\u5f00\u542fssh\u670d\u52a1\u8fdc\u7a0b\u8fde\u63a5<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[133],"tags":[134],"_links":{"self":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/743"}],"collection":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=743"}],"version-history":[{"count":2,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":746,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=\/wp\/v2\/posts\/743\/revisions\/746"}],"wp:attachment":[{"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/log.tanxiaodian.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}