openSSH

本文致力于合并收纳遇到的openSSH问题。

no matching key exchange method found.

报错会有后续内容提示比如:Their offer:diffie-hellman-group-exchange-sha1
原因:源主机密钥使用的算法过老如diffie-hellman-group-exchange-sha1,目的主机的openssh版本过高要求的密钥算法更高级。
解决方法:

  1. 升级源主机密钥。

  2. 源主机更新链接命令。

    1. ssh时指定:ssh -oKexAlgorithms=+diffie-hellman-group-exchange-sha1 ansuer@dest_vm
    2. 在链接配置中注解。
    echo -e "Host dest_ip
       User ansuer
       oKexAlgorithms +diffie-hellman-group-exchange-sha1" | sudo tee -a ~/.ssh/config
     
    
  3. 目的主机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远程开发时一直提示正在远程登录,无法正常获取到远程主机目录。

原因:

端口转发参数:AllowTcpForwardingAllowAgentForwarding
上述被设置为no即禁止了端口转发,可在systemctl status sshdjournalctl -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
posted @ 2024-04-18 07:44  土里的豆是土豆  阅读(3)  评论(0编辑  收藏  举报