Knowledge Base

How To secure your Vps After First login

  •  Log in to Your VPS Securely:
    • Connect to your VPS using SSH
  •  Change the Root Password:
    • If you received a default password, change it immediately
      • passwd 
                                                                                                                      
  • Update the Operating System
    • Keeping your system updated closes known security vulnerabilities 
      • apt update && apt upgrade -y

 

  • Create a New User (Avoid Using Root)  
    • Using root all the time is risky - create a new user 
      • adduser username 
    • Log in as the new user 
      • su - username 

           

  • Secure SSH Access
    • Edit ssh configuration   
      • nano /etc/ssh/sshd_config
    • Change or confirm the following
      • ( Port 2222 - PermitRootLogin no - PasswordAuthentication yes )
    • Save and restart SSH 
      • systemctl restart sshd


 
 


 

  • Enable a Firewall                                            
    • firewall-cmd --add-port=2222/tcp --permanent
    • firewall-cmd --add-service=http --permanent 
    • firewall-cmd --add-service=https --permanent
    • firewall-cmd --reload
            
  • Install Fail2Ban (Protection Against Brute Force Attacks) 
    • Fail2Ban blocks IPs after repeated failed login attempts
      • install fail2ban 
        • apt install fail2ban -y
        • dnf install fail2ban -y
        • systemctl enable fail2ban
        • systemctl start fail2ban 
      • Check status
        • systemctl status fail2ban
Please rate this article to help us improve our Knowledge Base.

0 0