{"id":160842,"date":"2019-11-01T11:08:25","date_gmt":"2019-11-01T03:08:25","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=160842"},"modified":"2019-10-17T11:09:30","modified_gmt":"2019-10-17T03:09:30","slug":"docker-ssh","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/docker-ssh.html","title":{"rendered":"\u901a\u8fc7ssh\u767b\u5f55docker\u5bb9\u5668"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u524d\u9762\u6587\u4e2d\u5df2\u7ecf\u4ecb\u7ecd\u4e86docker\u7684\u5b89\u88c5\u548c\u5bb9\u5668\u7684\u521b\u5efa\u7b49\uff0c\u4f46\u662f\u521b\u5efa\u51fa\u6765\u7684\u5bb9\u5668\u53ea\u80fd\u901a\u8fc7\u5bbf\u4e3b\u673a\u8fdb\u884c\u767b\u5f55\uff0c\u6709\u65f6\u5019\u8fd8\u662f\u5e0c\u671b\u76f4\u63a5\u901a\u8fc7SSH \u767b\u5f55\u5230docker\u5bb9\u5668\u4e2d\u8fdb\u884c\u4e00\u4e9b\u4fee\u6539\uff0c\u5176\u5b9e\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5c06\u5bb9\u5668\u4e2dssh\u7aef\u53e3\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\uff0c\u7136\u540e\u5728\u5bb9\u5668\u4e2d\u5b89\u88c5openssh \u670d\u52a1\u5373\u53ef\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u521b\u5efa\u5bb9\u5668\u65f6\u6307\u5b9a\u6620\u5c04\u7684\u7aef\u53e3<\/strong><\/span><\/div>\n
\r\ndocker run --name test -dit -p 8022:22  2c886f766286 \/bin\/bash\r\n<\/pre>\n

\u53e6\u5916\u5728\u5bbf\u4e3b\u673a\u4e0a\u4e5f\u662f\u53ef\u4ee5\u770b\u5230\u5bf9\u5e94\u7684\u7aef\u53e3\u662f\u5426\u88abdocker\u5bb9\u5668\u76d1\u542c\u4e86<\/p>\n

\r\nnetstat -tunlp\r\ntcp6       0      0 :::8022                 :::*                    LISTEN      24209\/docker-proxy\r\n<\/pre>\n
\u767b\u5f55\u5bb9\u5668\u4e2d\uff0c\u4fee\u6539root\u5bc6\u7801\uff0c\u5b89\u88c5openssh\u670d\u52a1<\/strong><\/span><\/div>\n
\r\ndocker exec -ti test \/bin\/bash\r\n[root@84641e8d0f74 \/]#passwd    #\u4fee\u6539\u5bb9\u5668\u4e2dcentos\u7cfb\u7edfROOT\u8d26\u6237\u7684\u5bc6\u7801\r\n[root@84641e8d0f74 \/]#yum -y install openssh*    #\u5b89\u88c5openssh\u670d\u52a1\r\n[root@84641e8d0f74 \/]#service sshd start\r\n<\/pre>\n
\u5bbf\u4e3b\u673a\u6dfb\u52a0\u7aef\u53e3\u653e\u884c<\/strong><\/span><\/div>\n
\r\niptables -A INPUT -p tcp --dport 8022 -j ACCEPT\r\nservice iptables save\r\n<\/pre>\n

\u8fdc\u7a0b\u767b\u5f55\u6d4b\u8bd5\u4e00\u4e0b\uff0c\u767b\u5f55\u6210\u529f\uff01<\/p>\n

\"\"<\/p>\n

\u4e3a\u4e86\u65b9\u4fbf\u4ee5\u540e\u4f7f\u7528\uff0c\u53ef\u4ee5\u5c06\u8fd9\u4e2a\u5f00\u542f\u4e86ssh\u767b\u5f55\u7684\u5bb9\u5668\u4fdd\u5b58\u4e3a\u955c\u50cf<\/strong><\/span><\/div>\n
\r\ndocker commit  84641e8d0f74  centos_6.6_ssh    #\u5bb9\u5668ID  \u521b\u5efa\u7684\u955c\u50cf\u540d\r\ndocker images   \u53ef\u4ee5\u770b\u5230\u8be5\u955c\u50cf\u5df2\u7ecf\u521b\u5efa\u6210\u529f\uff0c\u4e0b\u6b21\u9700\u8981\u65b0\u5efa\u5bb9\u5668\u65f6\u53ef\u76f4\u63a5\u4f7f\u7528\u8be5\u955c\u50cf\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

docker run –name test -dit -p 8022:22 2c886f766286 \/bi […]<\/p>\n","protected":false},"author":668,"featured_media":16254,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-160842","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\/160842","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\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=160842"}],"version-history":[{"count":8,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160842\/revisions"}],"predecessor-version":[{"id":161623,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160842\/revisions\/161623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/16254"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=160842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=160842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=160842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}