8 Bước Bảo Mật VPS Linux Hiệu Quả Nhất

Thứ tư, 30/07/2025, 13:16 GMT+7

1/ Đổi mật khẩu & không dùng root trực tiếp

  • Đặt mật khẩu mạnh, dài, khó đoán.

  • Tạo user mới:

           adduser tenuser
           usermod -aG sudo tenuser
           Tắt SSH đăng nhập root:
           Mở file:

           sudo nano /etc/ssh/sshd_config
           Tìm dòng:

           PermitRootLogin no

 

2/ Dùng SSH Key

  • Tạo SSH key:

         ssh-keygen -t rsa -b 4096
         Copy key:

         ssh-copy-id tenuser@IP-VPS
         Trong sshd_config:

         PasswordAuthentication no
         Khởi động lại SSH:

         sudo systemctl restart sshd

 

3/ Đổi port SSH

  • Trong sshd_config:

         Port 2222  # ví dụ
         Mở port mới trong firewall.

 

4/ Bật Firewall

  • Dùng ufw:

          sudo ufw allow 2222/tcp   # port SSH mới
          sudo ufw allow 80/tcp     # HTTP
          sudo ufw allow 443/tcp    # HTTPS
          sudo ufw enable
          sudo ufw status

 

5/ Cài Fail2ban

  • Chống dò pass brute-force:

          sudo apt install fail2ban -y
          sudo systemctl enable fail2ban
          sudo systemctl start fail2ban

 

  • Cập nhật hệ thống thường xuyên

sudo apt update && sudo apt upgrade -y

 

7/ Theo dõi log & tiến trình

  • Kiểm tra đăng nhập: last

  • Kiểm tra tiến trình lạ: htop
     

8/ Backup định kỳ

  • Backup tự động ra VPS khác / Google Drive / S3.



 

« Trở về trang chủ thiết kế web TRUST.vn