[ubuntu] ssh登录docker

进入容器后

# install ssh $ apt-get install openssh-client $ apt-get install openssh-server# start ssh service $ /etc/init.d/ssh start * Starting OpenBSD Secure Shell server sshd[ OK ] # enable root login $ vim /etc/ssh/sshd_config#------------ in file sshd_config -------------# # "PermitRootLogin yes" needs adding ... #LoginGraceTime 2m #PermitRootLogin prohibit-password PermitRootLogin yes #StrictModes yes #MaxAuthTries 6 #MaxSessions 10 ... #---------- end of file sshd_config -----------## restart service $ service ssh restart * Restarting OpenBSD Secure Shell server sshd[ OK ] # set password of user root $ passwd root# add port to ssh $ /usr/sbin/sshd -p 12345# checkout ip $ apt-get install net-tools $ ifconfig

【[ubuntu] ssh登录docker】在其他地方连接
$ ssh root@{ip got above} -p 12345

    推荐阅读