生活随笔
收集整理的這篇文章主要介紹了
docker ssh
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1,首先,需要從Docker官網(wǎng)獲得centos或Ubuntu鏡像
2,當(dāng)本地已有Ubuntu鏡像后(大概200M左右大小),使用如下命令
[cpp]view plaincopy
docker?run?-t?-i?ubuntu?/bin/bash??
即可啟動一個容器,并放入Ubuntu鏡像
3,更新源, apt-get update
接著就可以使用 apt-get install openssh-client openssh-server 來安裝openssh服務(wù)了
需要把此鏡像保存一下:
[cpp]view plaincopy
docker?commit?[container-id]?[image-id]??
在把剛剛的container干掉:
[cpp]view plaincopy
docker?stop?[container-id]??
嗯,還需要將這個container刪除掉
[csharp]view plaincopy
docker?rm?[container-id]??
最后,加載剛剛保存到的最新的image,放入到新的容器中去:
[cpp]view plaincopy
docker?run?--name?[image-name]?-i?-t?-p?50001:22?[image-id]??
4,啟動openssh服務(wù)
[cpp]view plaincopy
/etc/init.d/ssh?start??
5,此時可以從其他機(jī)器登陸到這個docker容器里了
6,可能出現(xiàn)一些錯誤使得一登陸進(jìn)去就直接關(guān)閉連接了:
[cpp]view plaincopy
[root@Wshare84?start_docker_sh]#?ssh?root@10.10.2.84?-p?50001?? The?authenticity?of?host?'[10.10.2.84]:50001?([10.10.2.84]:50001)'?can't?be?established.?? RSA?key?fingerprint?is?aa:05:84:4c:f2:15:f3:04:89:9c:04:33:0d:15:14:1f.?? Are?you?sure?you?want?to?continue?connecting?(yes/no)??yes?? Warning:?Permanently?added?'[10.10.2.84]:50001'?(RSA)?to?the?list?of?known?hosts.?? root@10.10.2.84's?password:??? Welcome?to?Ubuntu?14.04.1?LTS?(GNU/Linux?2.6.32-431.el6.x86_64?x86_64)?? ?? ?*?Documentation:??https:?? Last?login:?Wed?Jan?21?01:25:17?2015?from?172.17.42.1?? Connection?to?10.10.2.84?closed.??
此時解決方案:
[cpp]view plaincopy
ssh-keygen?-t?dsa?-f?/etc/ssh/ssh_host_dsa_key?? ssh-keygen?-t?rsa?-f??/etc/ssh/ssh_host_rsa_key??
[cpp]view plaincopy
echo?'root:yourpasswd'?|?chpasswd???
[cpp]view plaincopy
vi??/etc/ssh/sshd_config???
將PermitRootLogin 改為 yes,將?UsePAM ?改為 no。
重啟服務(wù):
[cpp]view plaincopy
/etc/init.d/ssh?restart??
總結(jié)
以上是生活随笔為你收集整理的docker ssh的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。