Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am able to ping my friend but not able to do ssh. Why so? He is using a modem. I thought there might be some firewall enabled. I told him to type

#iptables -F

He did that, but still I am not able to do ssh on his system. How can I do this?

I get the error: ssh: connect to host port 22: Connection refused

RESULT OF ifconfig on his system

 inet addr:  Mask:
inet addr:  Bcast:  Mask:

He told me his dynamic ip by using whatismyip.com

I tried ssh on that ip.

PS: sshd service is running on his system.
I tried nmap and came to know that port 22 is not opened.

share|improve this question
Does he have an SSH daemon (sshd) running? Also, is he behind a router? If he is, you'll need port forwarding enabled on the router. – sbtkd85 Sep 13 '11 at 17:24
Are you sure that sshd is running on that machine? It is listening on all interfaces/addresses (ListenAddress)? Are there any entries in /etc/hosts.deny? There is a local address at the interface, so is port 22 forwarded to that machine? – pbm Sep 13 '11 at 17:29
We both have different ISP. – Chankey Pathak Sep 13 '11 at 17:29
yes sshd is running. – Chankey Pathak Sep 13 '11 at 17:32
up vote 6 down vote accepted

As @sbtkd85 notes, it's almost certainly because port forwarding needs to be set up at his router/access point.

Here's some related/maybe pertinent info: http://forum.portforward.com/YaBB.cgi?num=1139203841

Cheers, Robert

share|improve this answer
The hint that NAT is happening between his friend and The Internet is this: inet addr: The 192.168.x.x address is a "non-routable" IP address reserved for use inside intranets. – Bruce Ediger Sep 13 '11 at 19:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.