Your attempt at copying to /etc/rc2.d/ssh
was almost right.
In order for a script in /etc/rcX.d
to be run at startup, it has to be called SxxZZZ
where S
is a literal S (for Start
; you can also use K
for Kill at shutdown time), xx
is a number representing where in the order of startup it runs (01 first, 99 last), and ZZZ
is your script name.
So, you'd want something like S90ssh
. The number isn't critically important, 90 should be ok, the network will be up by then etc.
Note it will also have to be set executable - I don't know if the system you're using will allow you to do that? Hopefully copying the existing ssh
script and simply renaming will keep the executable bits set.
As an alternative, /etc/rc.local
can be used as a generic all-purpose startup script. Simply drop /usr/sbin/sshd
in there before the exit line to get sshd
started as a last resort.
Give that a go and update your question if you're still having trouble :)
You can check in /var/log/auth.log
(/var/log/syslog
does not contain sshd messages by default) for a line like:
sshd[18838]: Server listening on 0.0.0.0 port 22.
to see if it's starting.
Best Answer
Try removing it completely
sudo apt-get purge openssh-server
And remove config dir
mv /etc/ssh /etc/ssh_old
Then
sudo mkdir /etc/ssh
Then install it again
sudo apt-get install openssh-server