6

Problem

I currently have my own Ubuntu server set up at home for development. However, when I try to ssh again after a certain period of time (about 20-30 minutes), it times out. Even after trying the ping command, no packets came back. If I do a physical reboot, ssh connection is possible without any problem.

What I want to solve

In order to be able to always ssh from another client PC even after a certain period of time has passed, I need to make the Ubuntu server sleep or suspend. Suspend? I'd like to know how to set it up so that it doesn't go into sleep/suspend mode.

Things I've tried

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

I disabled suspend and hibernate with this command and tried to reboot, but the result was the same.

  1. I found that for some reason, despite being an Ubuntu Server, I was able to change the gnome settings so I tried to change the settings with the following command.
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type nothing
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0

However, the result was the same here.

  1. I came across this question Ubuntu 20.04 keeps goes to sleep and tried it out but it did not work.

  2. I also changed the settings in the /etc/gdm3/greeter.dconf-defaults file as follows but there was no change even after rebooting after changing.

# Automatic suspend
# =================
[org/gnome/settings-daemon/plugins/power]
# - Time inactive in seconds before suspending with AC power.
# 1200=20 minutes, 0=never
# sleep-inactive-ac-timeout=1200
sleep-inactive-ac-timeout=0
# - What to do after sleep-inactive-ac-timeout
# 'blank', 'suspend', 'shutdown', 'hibernate', 'interactive' or 'nothing'.
# sleep-inactive-ac-type='suspend'
# - As above but when on battery
# sleep-inactive-battery-timeout=1200
sleep-inactive-battery-timeout=0
# sleep-inactive-battery-type='suspend'

System configuration

  • Ubuntu Server 20.04.2 LTS (GNU/Linux 5.4.0-80-generic x86_64)
  • AMD Ryzen 5950
  • AsRock Taichi X570

I would appreciate it if you could help me with a solution. Thank you very much for your help.

user76333
  • 171

2 Answers2

2

I run into the same error and I want to sum it up a little. Like @matigo mentioned, this is not a default behavior and comes with an UI. I didn't install it on purpose but when I was looking for my nvidia drivers by using ubuntu-drivers devices this was displayed:

enter image description here

The recommended driver was a non-server driver. With this installation I got an UI on board by mistake. The solution was like @hphex said here and as easy as firing this command:

sudo apt-get remove xserver-xorg-core

Be careful when picking the drivers, I hope this helps

1

SOLVED:

I had installed xcape which is written in my dotfiles for another Ubuntu desktop env.

After running this command from this post, removed all desktop related libraries and never went to sleep mode.

Remove GUI on Ubuntu Server

user76333
  • 171