Reboot through SSH not back online

5,735

Solution 1

Try the following:

    sudo shutdown -r now

Only used reboot once and had the problem your describing. Never used it again. Look at the shutdown man page for more options.

Can't say if this works on an encrypted home folder.

Solution 2

Make sure you have sshd service enabled.

sudo systemctl enable sshd.service
sudo systemctl start sshd.service
sudo systemctl status sshd.service

Upon restart, the service should be running allow you to login remotely. The service will look at your /home//.ssh/authorized_keys without the need to have the user first logged in on the remote machine.

As for your machine going to sleep after restart, make sure you have power setting set to always on and not go to suspend after inactivities as you want your remote machine to be running always.

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

Use umask to re-enable sleep and hibernate features.

If sshd service is net setup properly, try removing and re-install it.

sudo apt-get purge openssh-server
sudo apt-get install openssh-server

and confirm that it is running.

sudo systemctl status sshd.service
Share:
5,735

Related videos on Youtube

E.S.
Author by

E.S.

Updated on September 18, 2022

Comments

  • E.S.
    E.S. almost 2 years

    I am using Ubuntu 16 desktop, but I do plan to SSH into my machine just as much, if not more, than I use it as a desktop.

    I am noticing that when I issue an sudo reboot command while I am SSH'd in, the machine will reboot, but it will no longer be accessible via SSH. I notice the machine action will reboot then go into a sleep state.

    I am it set to allow network connections before log in and I have toggled "auto login" but neither worked.

    I really just want it to work like a typical Linux Server where SSH can be performed after a reboot. I would prefer the machine to reboot, then start up, fire up my profile tasks, and stay awake till I issue a sleep or shutdown command manually.

    Update: it was suggested that this issue would cover me (SSH is allowing remote connections only after a local login to the server) But I think it may be outdated as I do not have a /home/eric/.ssh/authorized_keys file... My SSH does work as along as I have already manually logged into my machine.

  • E.S.
    E.S. almost 6 years
    This is circumventing the problem though - other Linux server machines I have worked on did not fault like this. I'd rather ensure my settings are proper.
  • E.S.
    E.S. almost 6 years
    Although the machine didn't go back to sleep - I am not able to SSH into the machine remotely still. Also the first command sudo systemctl enable sshd.service resulted in the error: Failed to execute operation: Too many levels of symbolic links
  • btberch
    btberch almost 6 years
    Your question stated desktop not server. While you would expect them to act the same, for some reason they don't. My amd machines will use reboot. My intel machines won't. I'm using consumer and custom built machines. I don't know everything about linux, but have run my business on it for 19 years.
  • Bernard Wei
    Bernard Wei almost 6 years
    That's probably the problem, try removing sshd and then re-installing it again. If you know your setup, try purging it and re-install, that should fix that error.
  • E.S.
    E.S. almost 6 years
    Hmm what is the package name that I should run the apt-get against?
  • Bernard Wei
    Bernard Wei almost 6 years
    I've added the steps to the end of this answer thread. the package is openssh-server.