Docker使用ssh连接ubuntu容器

容器ssh配置

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

ssh连接容器

ssh root@localhost:2222

猜你喜欢

转载自blog.csdn.net/qq_67733273/article/details/133126764