
1. 禁用 root 用戶登錄
useradd?-m?examplerootpasswd?examplerootusermod?-aG?sudo?exampleroot
-
useradd 創建一個新用戶,并且 – m 參數在你創建的用戶的主目錄下創建一個文件夾。
-
passwd 命令用于為新用戶分配密碼。請記住,你分配給用戶的密碼應該很復雜且難以猜測。
-
usermod -aG sudo 將新創建的用戶添加到管理員組。
#?Authentication:?#LoginGraceTime?2m?PermitRootLogin?no?AllowUsers?exampleroot
>?rumenz@rumenz?/home/rumenz/www.rumenz.com??????????????????????????????>?sudo?systemctl?restart?ssh
>?rumenz@rumenz?/home/rumenz/www.rumenz.com>?sudo?systemctl?restart?sshd
2. 更改默認端口
Include?/etc/ssh/sshd_config.d/*.confPort?22099
3. 禁止使用空白密碼的用戶訪問
PermitEmptyPasswords?no
4. 限制登錄 / 訪問嘗試
牛逼??!接私活必備的?N?個開源項目!趕快收藏吧
MaxAuthTries?3
5. 使用 SSH 版本 2
Include?/etc/ssh/sshd_config.d/*.conf?Protocol?2
6. 關閉 TCP 端口轉發和 X11 轉發
X11Forwarding?no? AllowTcpForwarding?no
7. 使用 SSH 密鑰連接
ssh-keygen
8. SSH 連接的 IP 限制
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END