Đặ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
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
Trong sshd_config
:
Port 2222 # ví dụ
Mở port mới trong 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
sudo apt install fail2ban -y
sudo systemctl enable fail2ban
sudo systemctl start fail2ban
sudo apt update && sudo apt upgrade -y
Kiểm tra đăng nhập: last
Kiểm tra tiến trình lạ: htop
Backup tự động ra VPS khác / Google Drive / S3.
« Trở về trang chủ thiết kế web TRUST.vn