ping <Debian服务器IP>
命令测试网络是否可达。若无法ping通,需排查本地网络、路由器或服务器网络配置(如IP地址、子网掩码、网关是否正确)。sudo systemctl status ssh
,若服务未运行,用sudo systemctl start ssh
启动,并通过sudo systemctl enable ssh
设置开机自启。sudo ufw status
检查防火墙规则,确保允许SSH连接(默认端口22)。若未开放,执行sudo ufw allow ssh
放行。.pem
或.ppk
格式),并确认Debian服务器~/.ssh/authorized_keys
文件中包含对应的公钥。sshd_config
参数:编辑Debian服务器上的/etc/ssh/sshd_config
文件,确保以下关键配置正确(若不存在则添加):PermitRootLogin prohibit-password # 禁止root密码登录(推荐)
PasswordAuthentication yes # 允许密码认证(若用密码登录)
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256 # 支持常用密钥交换算法
修改后执行sudo systemctl restart ssh
重启SSH服务。sshd_config
中的KexAlgorithms
外,还需删除本地~/.ssh/known_hosts
文件和服务器~/.ssh/ssh2.ini
文件,重新连接建立信任关系。/etc/locale.conf
,设置LANG=en_US.UTF-8
,确保系统支持UTF-8编码。sudo tail -f /var/log/auth.log
(或/var/log/secure
),实时查看SSH连接日志,定位具体错误原因(如“invalid user”“permission denied”)。