Few days back I came across an issue on CentOS vps where the sshd service was failing,  everything looked fine and reinstall of the service did not work either.

There was no error shown at service startup, but the service status showed it was down :
-bash-3.2# /etc/init.d/sshd start
Starting sshd: [ OK ]
-bash-3.2# /etc/init.d/sshd status
openssh-daemon is stopped

I checked the /var/log/secure logs to see what error is being thrown and it showed below error :

Feb 8 13:54:54 vps sshd[18431]: fatal: daemon() failed: No such device

I had to do some search to find out which device its referring to in this error,  it turned out that its related to /dev/null which is suppossed to be a proper character device and not a regular file.

In this case it was a regular file so I removed it and recreated the character device as below :

-bash-3.2# rm -f /dev/null
-bash-3.2# mknod /dev/null c 1 3

Once the character device is created the permissions should look like below :

-bash-3.2# ls -lh /dev/null
crw-rw-rw- 1 root root 1, 3 Jan 12 16:07 /dev/null

After this was confirmed that /dev/null is a proper character device , I restarted the service and it came up fine this time :

-bash-3.2# /etc/init.d/sshd start
Starting sshd: [ OK ]
-bash-3.2# /etc/init.d/sshd status
openssh-daemon (pid 27662) is running...

So if you came across this error for ssh service failure, then make sure that /dev/null is a proper character device, recreating that as proper character device should fix the issue.

Tags: , , ,

7 Comments on sshd deamon failing to start

  1. Anonymous says:

    I was completely locked out of a Debian VPS that I use until I got the console restored and then followed this advice. Thanks~

  2. thinkevd says:

    Thank you so much?I donot how that error happened, but your tips really work?

  3. thinkevd says:

    After the system reboot, it stopped again. How about yours?
    Before I repair it ,
    #ls -lh /dev/null
    #-rw-r–r– 1 root root 1.7K Oct 9 15:09 /dev/null
    -bash-3.2# rm -f /dev/null
    -bash-3.2# mknod /dev/null c 1 3
    bash-3.2# ls -lh /dev/null
    crw——- 1 root root 1, 3 Oct 9 15:14 /dev/null
    bash-3.2#service sshd start
    Any advice?

  4. thesadmin says:

    Retains the value for me after reboots, you can try adding the steps to a init script under run level 3, so that they are performed automatically once the system/vps is rebooted.

  5. Mikko Östlund says:

    Hi thinkevd,
    It seems to me that you have a bug in some boot script. The bug probably
    looks something like:

    mv some_regular_file /dev/null

    If an ordinary user tries to execute the above, it simply fails with
    “permission denied”. However, the boot scripts execute as root and, then,
    the effect of the above will be equivalent to

    rm /dev/null
    mv some_regular_file /dev/null

    after which /dev/null will be the same *regular* file as
    “some_regular_file” was before it was moved. In the output of your
    “ls -lh /dev/null” command above I see that the size of your “/dev/null”
    is actually 1.7 kbytes, so if you look at its contents it may give you a
    hint on where it was moved from, and then maybe you can track down where
    that bug is. I’m curious to hear from you here if you find it.

  6. Keith says:

    Saved my behind! This document solved my sshd restart problem. What’s more interesting is that sshd would work in “debug” or “non-daemon” mode, but not in daemon mode (or started from init.d). Interesting that a clean RHEL5 install would have /dev/null as a regular file.

  7. John Poole says:

    I had the very same problem (Gentoo) and this fixed. Thank you!

Leave a Reply