10
Setting up openssh-server (1:5.3p1-3ubuntu7) ... 
Creating SSH2 RSA key; this may take some time ... 
Creating SSH2 DSA key; this may take some time ... 
start: Job failed to start

Can't initialize ssh, already tried reinstall.

SSH server is started manually via /etc/init.d/ssh start

netstat -nlp shows that no services are running at TCP port 22

3
  • Could you clarify in your question if you have tried starting it manually, ie sudo /etc/init.d/ssh start, and if so, did it give a different error than when you installed? Also, maybe you would want to install nmap and run nmap 127.0.0.1 to see if there is already a instance of ssh running and put the result in your question.
    – Azendale
    Jul 17, 2011 at 20:21
  • i tried to run it manually, and got the same thing
    – Frielspak
    Jul 17, 2011 at 23:14
  • Try to start once again the ssh daemon manually and then open /var/log/auth and check at the bottom of the file what the logs show...
    – Pavlos G.
    Aug 22, 2011 at 10:59

6 Answers 6

19

Not sure that my solution is right. But if you just want to start your SSH server and then solve your problem later, here is my fast solution:

start-stop-daemon --start --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- -p 22

if then you will see error:

Missing privilege separation directory: /var/run/sshd

then just create that missing directory, and try above start-stop-daemon command again:

mkdir /var/run/sshd
chmod 0755 /var/run/sshd

that helped me to start my sshd daemon.

2
  • 1
    This only fixes it for the current session. After a reboot that directory will be gone.
    – Malfist
    Nov 18, 2013 at 4:28
  • 2
    in the file /etc/init/ssh.conf add in the section pre-start script the folowing line :" mkdir -p -m0755 /var/run/sshd"
    – achabahe
    May 4, 2017 at 10:44
5

I had the same problem that sshd would not start because of error.
It showed that there was no directory /var/run/sshd.

ll  /var/run

showed a link to /run.
But on my system /run runs on ramdisk.
So I deleted the link and created the directories /var/run and /var/run/sshd. Now the sshd starts normally and I am able to reach my system over ssh again.

1

reconfiguring my firewall to allow port 22 worked for me.

ufw enable
ufw allow 22
0

There seem to be 3 issues resulting in this behavior (for my system Ubuntu 14.04LTS):

1- ssh unknown job occurs when you try to use 'service ssh start' from a 'su' session. Solution is to use sudo service start from a logged in user that can 'sudo'

2- The existing init.d/ssh script is exiting quietly without actually starting sshd when ssh is on upstart

3- The main reason ssh does not start is because on Ubuntu 14.04 there is an empty file /etc/ssh/sshd_host_not_to_run which indicates that sshd should not run. Just delete that file if you want sshd to run.

So overall solution is: Use sudo service ssh start after deleting /etc/ssh/sshd_host_not_to_run

0

Just re-install openssh-server:

sudo apt-get install --reinstall openssh-server
0

There's a bug report with a non-kluge solution to this bug

https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1811580

can be defused by implicitly setting 'UsePrivilegeSeparation no' in /etc/ssh/sshd_config,

re-installing doesn't necessarily fix it.

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.