Greetings, in this article I will list and explain as best I can some of the things that can make it difficult to connect to Home and Server systems from the outside. Have a good read.
1) Locking Root Account
Warning: Before you try what is written here on your Remote Server, be sure to do the Preparation in the SSH Hardening section, then come back here.
First of all, we close access to the root user. The reason is to prevent Brute Force attacks, which are very obvious.
Firstly, added a new account name with valen, and set a password for it.
Then added valen account to wheel group becouse we need root access for our new account.
After change user to valen and locked root account.
Finally root account is locked, but we need to check it with sudo cat /etc/shadow | grep root command. If you see root:! root account is successfully locked. ! means this user is locked.
2) SSH Hardening
Now we come to one of the most crucial parts. We need to make it more difficult for users to connect to the machine.
Preparation
Since we locked the root user above, our user does not have the .ssh folder and authorized_keys file. If you are going to lock the root user on a remote server, make sure to do this part first, otherwise you may lose access to the machine and you will have to deal with support.
a) Basic Security Settings for sshd_config File
b) Set Listen Address to Private VPN
At the moment the SSH service only listens to the VPN, but the firewall might not allow access there, so we have to write rules ourselves.