openssh默认不支持ssh-rsa

问题现象

openssh默认不支持 dss,rsa,执行报错:

1
Unable to negotiate with 192.168.1.12 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

解决方法

方法:修改openssh client 的全局配置

sudo vim /etc/ssh/ssh_config

1
2
3
Host *
    HostkeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa

方法:修改用户配置参数

vim $HOME/.ssh/config

1
2
3
Host *
    HostkeyAlgorithms +ssh-dss
    PubkeyAcceptedKeyTypes +ssh-dss

方法:命令行里面带加密协议参数:

1
2
3
ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa  user@192.168.1.12

GIT_SSH_COMMAND="ssh -oHostKeyAlgorithms=+ssh-dss -oPubkeyAcceptedAlgorithms=+ssh-rsa" git clone ssh://user@host/path-to-repository