连接被拒绝
sudo systemctl start ssh
,设置开机自启:sudo systemctl enable ssh
。sudo ufw disable
,或添加SSH规则sudo ufw allow ssh
。/etc/ssh/sshd_config
中Port
、ListenAddress
等参数正确。中文乱码
密钥交换方法不兼容
/etc/ssh/sshd_config
,添加以下内容:HostKeyAlgorithms=+ssh-rsa,ssh-dss
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256
重启SSH服务:sudo systemctl restart sshd
。权限不足
sudo
组或配置/etc/ssh/sshd_config
中PermitRootLogin
(谨慎使用)。~/.ssh
目录权限为700,authorized_keys
文件权限为600:chmod 700 ~/.ssh
,chmod 600 ~/.ssh/authorized_keys
。版本兼容性问题
密钥认证失败
chmod 600 ~/.ssh/id_rsa
。PubkeyAuthentication yes
,并确认authorized_keys
文件包含正确公钥。提示:操作前建议备份配置文件,若问题仍未解决可查看SecureCRT日志或服务端/var/log/auth.log
获取详细错误信息。