Monday, 3 December 2012

Sshd deamon failing to start

There was no error shown at service startup, but the service status showed it was down

 /etc/init.d/sshd start
 Starting sshd: [ OK ]

 /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

The error was  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 :

 rm -f /dev/null
 mknod /dev/null c 1 3

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

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

However, another error showed up when we tried to create /dev/null again

 mknod /dev/null c 1 3
 mknod: `/dev/null’: File exists

The solution for this was to create another /dev/null1 and renamed it to /dev/null

 mknod /dev/null1 c 1 3

 ll /dev/null1
 crw-r–r– 1 root root 1, 3 Jun  9 00:47 /dev/null1

 mv /dev/null1 /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 :

 /etc/init.d/sshd start
 Starting sshd: [ OK ]

 /etc/init.d/sshd status
 openssh-daemon (pid 27662) is running...