Securing Your SSH Server
SSH provides a powerful means to access your server with full root privileges, making its security crucial. Brute force attacks on SSH are common, posing a risk of unauthorized access or causing performance degradation due to increased traffic. Securing SSH can be accomplished in two ways:
Advanced Method: Disable SSH Password Login
- This method involves disabling SSH password login, requiring advanced Linux and CLI knowledge. Learn how to implement this method here[1].
Easy Method: Disable SSH Port (22) Using UFW
- For those less familiar with CLI or looking for a simpler approach, this method involves disabling the SSH port (22) using UFW, the default Linux firewall.
Follow these steps:
Retrieve your server’s IP address and password from your dashboard (
Servers=>Manage).Open your local terminal and connect to your server:
ssh root@your_server_ipEnter your password.
Check UFW status:
sudo ufw statusBy default, you may see:
Status: inactiveClose SSH port:
sudo ufw deny sshYou’ll see a “Rules updated” message.
Enable UFW:
sudo ufw enableReload UFW to apply the current settings:
sudo ufw reload
Now, if you log out, you won’t be able to connect to SSH, securing your server’s SSH port. To reconnect, use your dashboard console:
- Navigate to
Dashboard=>Servers=>Manage=> Click on theConsoleicon. - In the new window, enter your username (
root) and password. - Type:
sudo ufw allow ssh - Type:
sudo ufw reload
Now, you can reconnect to SSH on your local terminal and other devices. This method is suitable for protecting servers hosting apps or websites that don’t require frequent SSH access. For development stages, the advanced method is recommended.
[1]: https://www.cyberciti.biz/faq/how-to-disable-ssh-password-login-on-linux/
