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
。
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sudo sed -i -e '/^UseDNS.*no$/ s/no/yes/' -e '/^PermitRootLogin.*no$/ s/no/yes/' /etc/ssh/sshd_config
sudo systemctl restart sshd