How to Disable the Ubuntu ‘SSHD’ (SSH Server) Service on Desktop PCs

The Security Risk on Desktop PCs

In Ubuntu, the sshd (Secure Shell Daemon) service allows users to connect to the computer remotely via the command line from anywhere on the network (or the internet, if ports are forwarded). This is absolutely critical for managing headless servers in a data center.

However, if you are running Ubuntu Desktop on your personal laptop or a workstation in an office, having the SSH server running is a significant security risk. If you have a weak user password, an attacker on the same Wi-Fi network could potentially brute-force their way into your machine and gain full terminal access. If you never intend to remotely log into your desktop PC, you should completely disable the SSH daemon.

How to Disable the SSH Server Service

You can turn off remote access using systemctl.

  1. Open your Ubuntu Terminal (Ctrl + Alt + T).
  2. First, stop the service immediately to sever any active connections and close port 22:
sudo systemctl stop ssh.service

(Note: Depending on how SSH was installed, the service might be named sshd.service instead).

  1. Next, disable the service so it does not start up automatically when you reboot your computer:
sudo systemctl disable ssh.service
  1. If you want to go a step further and ensure that the SSH daemon cannot be started even manually by mistake, you can mask it:
sudo systemctl mask ssh.service

Your Ubuntu desktop is now secured against remote SSH login attempts. If you ever need to access your machine remotely in the future, you can easily reverse this process by unmasking and enabling the service.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.