## 下载镜像
docker pull docker.io/matosiki/centos7_ssh:1.0
## 启动镜像
docker run -d -p 2222:22 docker.io/matosiki/centos7_ssh:1.0 /usr/sbin/sshd -D
## ssh 连接
ssh root@localhost -p 2222
docker run -it centos:latest /bin/bash
# 安装sshd
yum -y install openssh-server
yum -y install openssh-clients
# 启动sshd服务
/usr/sbin/sshd -D
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ""
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
# 编辑sshd_config配置文件
vim /etc/ssh/sshd_config
UsePAM no
# 退出容器
exit;
# 构建新的镜像
docker commit <centos_id> docker.io/matosiki/centos7_ssh
# 推送到远程仓库
docker push docker.io/matosiki/centos7_ssh:1.0
Content type
Image
Digest
Size
106.8 MB
Last updated
almost 8 years ago
docker pull matosiki/centos7_ssh:1.0