Connect with us

Hi, what are you looking for?


How to Harden SSH to Secure a Linux VPS Server

How to Harden SSH to Secure a Linux VPS Server. The SSH plays most important role when perform any remote login to any Linux server. That’s why it is the first targeted method by any hacker to compromise a Linux server. First step that is performed by any sysadmins or devops is to harden SSH to secure it from external attacks and hackers. This tutorial explains you how to secure Linux SSH servers using SSH Hardening Tips.

Tip 1 : Enable Firewall To Protect the SSH Ports

You need to integrate the firewall to protect your SSH Port using IPtables or UFW firewall.

Tip 2 : Enable SSH Key based authentication instead of password based authentication

First of all you need to enable the key based SSH authentication to protect your SSH servers.

Tip 3 : Harden your sshd configuration file

Edit your SSH configuration file

Advertisement. Scroll to continue reading.
# vi /etc/ssh/sshd_config

Find the given lines

PermitRootLogin yes
PasswordAuthentication yes
AllowTcpForwarding YES
ClientAliveCountMax 3
Compression DELAYED
LogLevel INFO
MaxAuthTries 6
MaxSessions 10
Port 22
TCPKeepAlive YES
UsePrivilegeSeparation YES
X11Forwarding YES
AllowAgentForwarding YES

Change it to

PermitRootLogin no
PasswordAuthentication no
AllowTcpForwarding NO
ClientAliveCountMax 2
Compression NO
MaxAuthTries 2
MaxSessions 2
Port 3526
TCPKeepAlive NO
UsePrivilegeSeparation SANDBOX
X11Forwarding NO
AllowAgentForwarding NO

Restart the SSH services to apply the changes.

# systemctl restart sshd


Advertisement. Scroll to continue reading.
# service sshd restart
Tip 4 : Integrate Advanced Diffie-Hellman Key based algorithm to secure SSH

Integrate Advanced Diffie-Hellman key based algorithm to enhance the security of SSH server.

Tip 5 : Limit SSH Brute-force attack using Fail2ban

Limit SSH Brute-force attack using Fail2ban
Install Fail2ban on Ubuntu / Debian based Distro

# apt-get install fail2ban -y

Install Fail2ban on RHEL / CentOS based Distro

Note: you need to install EPEL repository first before proceeding to the given steps

# yum install fail2ban -y

Enable the fail2ban on linux Distro

Advertisement. Scroll to continue reading.
# cp -rv /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

Start the fail2ban services to apply the changes.

# systemctl start fail2ban


# system fail2ban start


Finally you have harden and secured the SSH servers from external attacks implementing above tips to your Linux VPS servers. If you have issues you can use the comment section below.

Advertisement. Scroll to continue reading.

You May Also Like


How to auto upgrade JioFi firmware for JioFi 2 / JioFi 3 / JioFi 4 / JioFi 5 / JioFi 6 and other JioFi...


Internet is the most important public network for connecting to the WEB. For internet connection requirement the ISP is required as well as it...


How to download and install the Mobile Intel 4 Series Express Chipset Graphics Drivers for Windows 10.  Windows 10 is the one of the...


How to Install and Configure PCSX2 on Windows 10. The Windows 10 is the most recommended operating system for the Games. In stream platform...