docker allows host ssh to connect to the docker container
- 2020-06-15 10:31:50
- OfStack
In the docker container, install ssh:
1) Replace the installation source in the container with 163 source
2) Install ssh services
apt-get update
apt-get install openssh-server
3) Add directory and modify ssh configuration file
mkdir -p /var/run/sshd
vim /etc/pam.d/sshd
Find the line session required pam_loginuid.so and comment it out
4) Add the host public key to be linked to
Put the public key in /root/.ssh /authorized_key
The next step is to start the container on the host, allocate the port, and enable THE ssh service:
docker run -p 10022:22 -d sshd:ubuntu /usr/sbin/sshd -D
Try the link:
ssh 192.168.163.131 -p 10022
ip is the host for the container, ip