I am having trouble using ssh. I seem to be able to ssh out of the machine, but I can not locally ssh to the machine, nor can i ssh from a remote machine. I have checked the /etc/ssh/ssh_config and /etc/ssh/sshd_config, and when I start the service it states that it is OK, but when checking the status I get "openssh-daemon is stopped". What am I doing wrong?

I working with Centos 6.3 and about to lose whatever hair I have

netstat -int | grep 22 gives no response and shows that most of the xinetd services are off

Dirk ssh -v -v -v returns nothing, and I am get no log information. the problem is the openssh which does not start even when it is started.

  • 1
    Can you see a listen port? netstat -lnt | grep 22 What does chkconfig --list sshd say? – Rich Homolka Mar 11 '13 at 20:27
  • How do you start the service? How do you get the status? Do you have a firewall activated? Is the ssh port you are using in the firewall rules? Which is your sshd port (you can get it with grep -i ^port /etc/ssh/sshd_config). – erik Mar 11 '13 at 20:43
  • @ray, if you don't have anything listening, it obviously won't let you log in. Try service sshd start and then see if it's listening. – Rich Homolka Mar 11 '13 at 21:02
  • We're working on getting your accounts merged. Once that's done, you can add comments to answers below. – slhck Mar 11 '13 at 21:11

To debug your problem you may inspect the output of ssh -v -v -v ....

Also you may increase the sshd logging level in the /etc/ssh/sshd_config

  LogLevel DEBUG

The logging output goes normally to /var/log/auth.log.

|improve this answer|||||
  • ssh -vvv also does the job ;) – 0xC0000022L Mar 11 '13 at 20:47

Dirk ssh -v -v -v returns nothing, and I am get no log information. the problem is the openssh which does not start even when it is started.

Indicates that the problem is the daemon which doesn't start.

Run this (sudo chkconfig --list sshd), and show us the output. On my machine it looks as follows:

$ chkconfig --list sshd
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off

also run service sshd restart and show the output - should look like this, first line is likely "Failed" or so in your case:

$ sudo service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]

To start it upon boot do:

sudo chkconfig sshd on

and list again what it looks like with

chkconfig --list sshd

After that step continue debugging with the steps outlined below the horizontal rule if you're still having trouble.

First verify sshd is indeed running on its default port:

sudo lsof -i :22

(you can also use one of the netstat lines suggested in comments).

Assuming Linux - you gave no indication which OS you are using - try something along the lines of /etc/init/sshd restart. The name of the service could of course differ, e.g. be openssh, ssh or so ...

What I have been doing in the past to diagnose ssh problems both on the server-side and the client-side is something similar to what Dirk suggests in his answer ... but extended.

You want to use the same machine, fine. So run in one tab/window the command (for the "server"):

sudo $(which sshd) -dDp 22222

on the client side run:

ssh -vvvvp 22222 localhost

Does the first tab/window show anything? If it doesn't we already have an indication. It's likely some weird firewall rule or you gave some strange setting for the Listen directive in /etc/ssh/sshd_config. If that's the case please paste it and we'll go from there.

|improve this answer|||||
  • The reason for the somewhat convoluted sudo $(which sshd) -dDp 22222 is that sshd wants to be run with its absolute path and refuses to run otherwise. At least on some of my systems. Of course you could also separate these steps. – 0xC0000022L Mar 11 '13 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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