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 new to ssh on linux. I have two computers connected on a switch. The first one is and the second is When I use the ping command I got a reply and everything is good, but when I use ssh from the frist computer ssh -v user@ it gives me,

OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to [] port 22.
debug1: connect to address port 22: Connection timed out

I have ssh installed on both machines. Any ideas on how I can fix this problem?

share|improve this question

migrated from stackoverflow.com Jul 14 '11 at 0:45

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

Check these things:

  • Port 22 open and can receive connections
  • Make sure OpenSSH or another SSH process is running on the server
  • Make sure the SSH configuration file is given the appropriate values
share|improve this answer
mmm. man sshd_config |grep -i appropriate comes up empty on all my linux boxes, and Solaris too – sehe Jul 14 '11 at 0:00
@sehe The file isn't located under /etc/ssh/? – norway28 Jul 14 '11 at 0:20
This made me <headdesk/> even while in bed. Sarcasm fail. What I (mockingly) suggested, is the documentation does not contain info on the appropriate (sic) settings – sehe Jul 14 '11 at 0:34
thanks for all,actually port 22 was close so I have inserted this command [code] iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 22 -j ACCEPT [/code] – sam Jul 14 '11 at 1:46

Troubleshooting tips:

  • Can you ssh localhost on the server?
  • Are users allowed? (AllowUsers setting)
  • Do you bind to the external NIC? (look for ListenAddress or ListenAddress ::)
  • Are you running on port 22? (Port)

    • Basically check /etc/ssh/sshd_config.
  • Added: you can use netstat -tlpn | grep 22 to find out what programs (if any) are listening on port 22 (run as root to see the process names) .

Also, consider using an explicit port connect instead of ping (e.g. nmap -PN remote -p22 or even just telnet remote 22)

share|improve this answer
thanks for help – sam Jul 14 '11 at 1:42

First, check if SSH is running on the receiving end. Login to the remote machine and try to ssh to localhost (ssh to the same machine you are on).

ssh -v myUserName@localhost

This should prompt for your password and then should log you into the same machine. If this does not work, that means that this host does not have SSH enabled. Enabling "remote login" on this server should fix the problem.

If however you were able to ssh from the target server into itself successfully, then the issue is likely somewhere in the middle. Your next thing to check is firewalls on the source host to make sure they are not blocking ssh.

share|improve this answer
I call hand-waivy: Enabling "remote login" doesn't actually mean anything. Fixing the problem should also enable "remote login", FWIW – sehe Jul 13 '11 at 23:58

Check following things:

1) Run nmap localhost and check port 22 status

2) On your second computer with which you want to connect through ssh, perform ssh localhost

share|improve this answer

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.