I want to restart an Ubuntu 18.04.4 LTS machine through ssh. I do not have physical access to that machine.
How can I make sure that the ssh service starts automatically on boot so that I can connect again after restart?
02 Answers
From a terminal run systemctl list-unit-files | grep ssh and if the service says enabled it should start back up when the system reboots.
$ systemctl list-unit-files | grep ssh
ssh.service enabled
ssh@.service static
sshd.service enabled
ssh.socket disabled And you can check the current status of ssh by running systemctl | grep ssh
$ systemctl | grep ssh
ssh.service loaded active running OpenBSD Secure Shell server Hope this helps!
You can use the reload command. What this does is leave access to ssh while it goes through the process testing your changes in your sshd config file. If there are problems it will error out, so you can fix them. Then you go through the process until everything loads fine. After it reloads, then you can run a restart.
However, if you still feel you need another way, you can run another ssh daemon on a different port, that you can bring up and down and set to start up on reboot as well, and after everything is configured with the ssh you wanted to configure works, you can disable the backup daemon from restarting on bootup.