I've a VPS with Ubuntu 18.04Lts on Google Cloud.
On every reboot, I've to start the ssh daemon service either by service ssh(d) start
or systemctl start ssh(d)
(both ssh and sshd work the similar way and start the needed service.
But its very difficult and cumbersome to start the server on serial ports and then start the ssh service on the server. I've tried the following ways to configure the service to start behind it. I've found all the ways in diff articles found thru google or on Stack answers (I don't know the reasons/logics behind them). I did them one by one, mostly without first undoing the prev one.
- Tried installing and reinstalling the openssh-server.
- Ran this command:
sudo systemctl enable sshd.service
- Ran this command:
systemctl enable sshd
- Ran this command:
sudo update-rc.d sshd defaults
- Ran this command:
systemctl enable ssh.socket
- Checked that symbolic link of
/etc/rc*.d/S**ssh
are there - Commenting out the specific
ListenAddress
directive and addingListenAddress 0.0.0.0
to let sshd listen on any address in the file : /etc/ssh/sshd_config. - Edited this line
# Required-Start: $remote_fs $syslog
to this line# Required-Start: $remote_fs $syslog $network
in the file /etc/init.d./ssh (to stop sshd from starting before the network is ready). - Added this line:
sshd &
to the (end of) file/etc/init.d/rc.local
. - Edited this file:
/etc/rc.local
and added this line:/etc/init.d/ssh start
- Edited the
/etc/ssh/sshd_config
file and in it, change Port to 2222. Also set thePasswordAuthentication
toyes
. - Added/tried these lines in root's crontab file:
@reboot mkdir -p -m0755 /var/run/sshd && systemctl restart ssh.service
. Didn't work, then tried this@ systemctl restart ssh.service
. then commented out this also, And tried this:@reboot service ssh start
. But again, commented out this one and tried this last one:@reboot sleep 15 && /bin/systemctl restart sshd
.
Even after trying these 15 solutions, the ssh service still doesn't start upon reboot.
Kindly do help.