Docker Community Forums

Share and learn in the Docker community.

How to login to a container through ssh/Putty from another host


(Joshlingard) #1

I have created a container with RHEL 7.4 inside a host with RHEL 7.4 as well.

I have used Macvlan network driver as shown in https://docs.docker.com/engine/userguide/networking/get-started-macvlan/

So now I can ping the IP of my container from another host in the same network.

My host’s ip where docker is installed is 172.xx.xx.105 and another host’s ip is 172.xx.xx.106 and my container’s ip is 192.xx.x.10.

How can I ssh to my container’s IP(192.xx.x.10) from another host (172.xx.xx.106) or just directly ssh to my container’s ip directly from a putty?


(Sam) #2

you will have to install and start the ssh server in the container, as typically this isn’t in the starter image.


(Joshlingard) #3

SSH is installed in the Container and I can ssh from the container to the another host without any problem.

The only problem is sshing from another host to the container.

Here is the message I receive

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving “192.xx.x.10” port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 192.xx.x.10 [192.xx.x.10] port 22.
debug1: connect to address 192.xx.x.10 port 22: Connection refused
ssh: connect to host 192.xx.x.10 port 22: Connection refused


(Sam) #4

well, there is ssh client (the ssh command) and there is ssh server (sshd). you need the server installed on your container to be able to ssh into it from another system


(Jjlorenzo) #5

And you need that the ssh server (sshd) is started in the container