If you are using SSH keys, disabling password-based access to the server will be a valuable additional security measure.
Disabling via nano
Use the following command:
nano /etc/ssh/sshd_config
This will take you to the sshd configuration file.
Find the line PasswordAuthentication yes.
You need to remove the hash (#) to make the line active. Then, change the value from yes to no.
Press the Ctrl + X key combination, and enter Y to save.
Restart the SSH service:
sudo service ssh restart
Disabling via sFTP
In the file manager panel, erase the default path /root and specify /etc/ssh. In this directory, open the sshd_config file.
Find the corresponding line PasswordAuthentication yes.
Remove the hash (#) to make the line active. Then, change the value from yes to no.
Save the file and upload it to the server.
Restart the SSH service:
sudo service ssh restart
Using SSH Key in sFTP
After enabling access only through SSH keys, you may encounter an issue when connecting via sFTP. This issue can be resolved quite easily.
FileZilla
Click on the "Edit" category and select "Settings."
Then, choose the "sFTP" page and click on the "Add key file" button.
Select the location and add the file.
The key is added, and now FileZilla will use it when attempting to connect to servers.
WinSCP
Click the button to create a new connection:
A window opens. Here, specify the server's IP address and Username.
Use the "More" button below the Password field.
In the opened window, select the "Authentication" section.
Add the private key and click "OK."
Try connecting to the server.
The program prompts for the key's secret code; enter "spacecore"
You have successfully connected to the server!