openSSH常见问题
本文致力于合并收纳遇到的openSSH问题。
no matching key exchange method found.
报错会有后续内容提示比如:Their offer:diffie-hellman-group-exchange-sha1。
原因:源主机密钥使用的算法过老如diffie-hellman-group-exchange-sha1,目的主机的openssh版本过高要求的密钥算法更高级。
解决方法:
-
升级源主机密钥。
-
源主机更新链接命令。
ssh时指定:ssh -oKexAlgorithms=+diffie-hellman-group-exchange-sha1 ansuer@dest_vm。- 在链接配置中注解。
echo -e "Host dest_ip User ansuer oKexAlgorithms +diffie-hellman-group-exchange-sha1" | sudo tee -a ~/.ssh/config -
目的主机
openssh放行。echo "KexAlgorithms +diffie-hellman-group-exchange-sha1" | sudo tee -a /etc/ssh/sshd_config systemctl restart sshd
Permission denied (publickey,gssapi-with-mic)
部分系统不支持rsa算法,我在mac上遇到。
解决方法:
在本机(而非远程)~/.ssh/config添加配置
Host *
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
refused local port forward originator
使用VSCode远程开发时一直提示正在远程登录,无法正常获取到远程主机目录。
原因:
端口转发参数:AllowTcpForwarding 和 AllowAgentForwarding。
上述被设置为no即禁止了端口转发,可在systemctl status sshd或journalctl -u sshd看到如题报错。
解决方法:
修改相关参数值为yes,并systemctl restart sshd。
root登陆失败
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sudo sed -i -e '/^PermitRootLogin.*no$/ s/no/yes/' /etc/ssh/sshd_config
sudo systemctl restart sshd

浙公网安备 33010602011771号