Restrict root ssh access to a single IP under Raspbian / Debian / Ubuntu

Today I configured a new backup solution that required me to restrict root ssh access to a single IP for the root user.

I got this to work by going the following steps (on Raspbian GNU/Linux 9):

  1. login via ssh on the machine to access via root
  2. modify the /etc/ssh/sshd_config like that:
  3. add the following lines to the end of the file:

    As you can see, I additionally changed the default ssh port from 22 to 666 for a little bit more confusion of potential hackers ūüėČ

  4. after saving the file (Ctrl+o and Ctrl+x), I validated the configuration by:

  5. and finally I restarted the ssh daemon by:

That’s how to restrict root ssh access to a single IP under Raspbian! Afterwards I could only login from the machine¬†192.0.0.66 using the root user.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.