容器ssh配置
- 启动容器
sh
docker run -it -p 2222:22 ubuntu
- 更新
sh
apt update
- 配置密码
sh
passwd
- 安装openssh-server
sh
apt install openssh-server
- 配置ssh
sh
echo "UsePAM no" >> /etc/ssh/sshd_config
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
- 启动ssh
sh
service ssh start
ssh连接容器
sh
ssh root@localhost:2222