Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 trying to setup one of my linux computers as an ssh server but I can't connect to it.

I have openssh-server and openssh-client installed already on both computers (client and server).

If I run sudo service ssh start, I get start: Job is already running: ssh, so ssh is indeed running. Also, ps aux | grep -i ssh returns

1000 2270 0.0 0.0 4080 24 ? Ss 06:04 0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session mate-session

1000 2286 0.0 0.3 59104 7832 ? Sl 06:04 0:00 /usr/bin/mate-keyring-daemon --start --components=ssh

1000 6333 0.0 0.0 6684 1132 ? Ss 07:29 0:00 /usr/sbin/sshd

root 12622 0.0 0.1 6684 2432 ? Ss 08:09 0:00 /usr/sbin/sshd -D

1000 13978 0.0 0.0 4392 844 pts/0 S+ 08:33 0:00 grep --color=auto -i ssh

If I run ssh localhost on the server, I can connect. But if I try that with the other computer on the lan, it doesn't work.

I have samba shares setup and working, so I don't think its a firewall problem.

Any help would be appreciated.

share|improve this question
What exact command are you running to connect from the other machine? And what is the output if you append -vvv (very very verbose) to the ssh command on the client? And what do logs on your server say? (/var/log/syslog, /var/log/auth.log) "it doesn't work" is very vague :) – gertvdijk Feb 9 '13 at 13:43 – flyingfisch Feb 9 '13 at 13:47
Why are you connecting to localhost on the client machine? Use the host name or IP address of the target machine (server) you want to connect to! – gertvdijk Feb 9 '13 at 13:49
just did that and now it works. solved. :) – flyingfisch Feb 9 '13 at 13:52

Check if ssh is listening at port

$ sudo netstat -putan | grep LIST | grep 22
tcp        0      0    *               LISTEN      4330/sshd       
tcp6       0      0 :::22                   :::*                    LISTEN      4330/sshd       

If it is listening, check if you have a firewall:

sudo iptables -L INPUT -n -v

If appears lots of lines, you could have UFW enabled check it using: sudo ufw status

If it is enabled try to add a rule to permit ssh:

 sudo ufw allow ssh

After that try to connect to ssh again. If it doesn't work you can disable the firewall completly with the next line and try again: sudo iptables -F

(note the above line is not permanent, so if you reboot the computer the firewall could start again, disable or configure your firewall correctly)

share|improve this answer
It's a nice explanation, but that wasn't what the question is about. As you can read in the comments, the OP was trying to connect from client to client instead of client to server. – gertvdijk Feb 10 '13 at 18:20

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.