How to Disable Root Access over SFTP?
Root access over SFTP is one of the most vulnerable aspects of web server security. If attackers gain access to the root account through SFTP, they can completely control your server and cause irreparable damage. Therefore, it is very important to disable root access over SFTP.
To do this, simply follow these simple steps:
Step 1: Create a New User
First of all, create a new user with limited privileges. This user will be used for SFTP access instead of root. To do this, execute the following command:
sudo adduser newuser
Step 2: Configure the Firewall
Next, you need to configure the firewall to allow access to the server only to the new user. To do this, use the following command:
sudo ufw allow ssh
sudo ufw allow out 22
Step 3: Disable Root Access
Now disable root access over SFTP. To do this, edit the SSH configuration file:
sudo nano /etc/ssh/sshd_config
Find the line PermitRootLogin yes
and change it to PermitRootLogin no
. After making changes, save the file and restart the SSH service:
sudo systemctl restart sshd
Congratulations! Root access over SFTP is now disabled, and your server has become more secure. Be careful and monitor security updates to protect your system from new threats.