要提升Ubuntu SSH的安全性,可以采取以下措施:
sudo apt update
sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl status ssh
/etc/ssh/sshd_config
文件,设置以下参数:Port 2222 # 更改默认端口
PermitRootLogin no # 禁用root登录
PasswordAuthentication no # 禁用密码登录,推荐使用密钥登录
Match Group sftp_users
ChrootDirectory /home/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp
sudo systemctl restart ssh
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh-copy-id user@your_server_ip
sudo ufw allow ssh
sudo ufw enable
/etc/ssh/sshd_config
,添加 AllowUsers
和 AllowGroups
选项,限制允许连接的用户和组。sudo apt update && sudo apt upgrade
sudo apt install unattended-upgrades
sudo cat /var/log/auth.log | grep 'sshd'
/etc/fail2ban/jail.conf
文件。通过上述措施,可以显著提高Ubuntu SSH的安全性,保护系统和数据不受未经授权的访问和攻击。