On my Linux machine, I have services enabled for SSH. However, whenever /usr/sbin/sshd is init, it fails to daemonize. No sshd.pid file is generated under /var/run and sshd is not running when I do a 'ps'.

The strange thing is that when I run sshd in non-daemon mode (ie. '/usr/sbin/sshd -D') or if I run it in debug mode (ie. 'usr/sbin/sshd -d'), sshd is able to run and sshd.pid file is generated under /var/run.

I've also verified that default port 22 is available and not being used by another process. Also, when I try different ports, I observe the same behavior detailed above.

Any idea why this might be happening?


  • Have you looked at the logs? Jan 1, 2020 at 0:10
  • Yes, unfortunately, the logs are not showing any useful info on why this is happening Jan 2, 2020 at 18:20

1 Answer 1


Can I ask what you see if you do:

 /usr/sbin/sshd -p 10022 -d

What that will do is start a brand new sshd on port 100222 in debug mode (remaining in the foreground). This is one from my system where it has started ok:

This is the output I see from a working one:
debug1: sshd version OpenSSH_7.4, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: private host key #0: ssh-rsa SHA256:MSjzB8S5CxN8QBBis8FWehZT66qV0IgUT1ayBjUxRJc
debug1: private host key #1: ecdsa-sha2-nistp256 SHA256:rc8cgnqJVCdab+vzUZMlGxr9a9R9Bq9kv+VsMitLpjE
debug1: private host key #2: ssh-ed25519 SHA256:c1TzuNsEHvgqObVuKe1E5Km9pYDg76yqeZzZim3XJWI
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-p'
debug1: rexec_argv[2]='10022'
debug1: rexec_argv[3]='-d'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 10022 on
Server listening on port 10022.
debug1: Bind to port 10022 on ::.
Server listening on :: port 10022.

If you could run the above and post the output it might reveal more about what is not working.

  • This works and I see what you are seeing. I've actually narrowed down to the daemon() function in the sshd code that is not returning for some reason. Jan 3, 2020 at 21:48
  • Can you run it under ```strace -f ``? fromt the command line?
    – gm3dmo
    Jan 4, 2020 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .