Connection refused when trying to SSH but port 22 is not blocked.

Support for security such as Firewalls and securing linux
Post Reply
Kiran77
Posts: 5
Joined: 2016/04/13 00:07:10

Connection refused when trying to SSH but port 22 is not blocked.

Post by Kiran77 » 2016/04/13 00:19:34

I'm running CentOS 7 VMs and open source Docker. I want to SSH to Docker containers from other VMs or other Docker containers. How do I do this?

I can SSH from the Docker containers to their shared host VM. I cannot SSH into the Docker containers from the host VM because of an error "Connection refused." I cannot SSH to the Docker containers from the containers themselves because of "connection refused." nmap results show that ports 1 through 1000 are closed but not filtered on each container. I tested against the IP address in the result of a docker inspect command.

I can ping the DOcker containers from each other using their IP addresses. sftp between the containers fails because of "connection refused." Given that there is no firewall rule on port 22, what is causing this "connection refused" problem?

If you are not familiar with Docker, can you provide me with possible root causes given that nmap rules out port blockage? Pings work. Docker containers function VERY similarly to Linux servers.

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Connection refused when trying to SSH but port 22 is not blocked.

Post by aks » 2016/04/13 16:31:31

Docker containers function VERY similarly to Linux servers.
Well no, not really, especially at the networking level.

Have you exposed port 22 in the container? Given it's closed I suspect not.

A place to start: https://docs.docker.com/engine/userguid ... rnetworks/

BTW, ping != tcp connect.

Kiran77
Posts: 5
Joined: 2016/04/13 00:07:10

Re: Connection refused when trying to SSH but port 22 is not blocked.

Post by Kiran77 » 2016/04/14 00:04:25

Can you elaborate on why "ping != tcp connect"?

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: Connection refused when trying to SSH but port 22 is not blocked.

Post by scottro » 2016/04/14 01:45:56

The ping command uses the icmp protocol. A TCP connection uses syn, ack, and then synack. Also, many things block icmp by default.
New users should check the FAQ and Read Me First pages

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: Connection refused when trying to SSH but port 22 is not blocked.

Post by aks » 2016/04/14 18:29:15

Ditto, what he ^^^^ said

fwiffo
Posts: 5
Joined: 2016/03/30 19:38:25

Re: Connection refused when trying to SSH but port 22 is not blocked.

Post by fwiffo » 2016/04/15 03:16:06

telnet <hostname> 22

if you want to test to see if port 22 is blocked

Post Reply