You are here:

Securing Your SSH Server

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:

  1. 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].
  2. 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:

  1. Retrieve your server’s IP address and password from your dashboard (Servers => Manage).

  2. Open your local terminal and connect to your server:

    ssh root@your_server_ip

    Enter your password.

  3. Check UFW status:

    sudo ufw status

    By default, you may see:

    Status: inactive
  4. Close SSH port:

    sudo ufw deny ssh

    You’ll see a “Rules updated” message.

  5. Enable UFW:

    sudo ufw enable
  6. Reload 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:

  1. Navigate to Dashboard => Servers => Manage => Click on the Console icon.
  2. In the new window, enter your username (root) and password.
  3. Type:
    sudo ufw allow ssh
  4. 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/

Was this article helpful?
Dislike 0