本文共 383 字,大约阅读时间需要 1 分钟。
在docker容器中,安装好ssh:
1)替换掉容器中的安装源为163源
2)安装ssh服务
apt-get updateapt-get install openssh-server3)添加目录,修改ssh配置文件
mkdir -p /var/run/sshdvim /etc/pam.d/sshd 找到 session required pam_loginuid.so 这一行,将它注释掉4)添加要链接过来的主机公钥
将公钥放到/root/.ssh/authorized_key中
接下来就是在宿主机上启动容器,分配端口,启用ssh服务:
docker run -p 10022:22 -d sshd:ubuntu /usr/sbin/sshd -D尝试链接:
ssh 192.168.163.131 -p 10022ip 为容器的宿主机ip
转载地址:http://dcxgi.baihongyu.com/