ssh 遠端登入報錯:Unable to negotiate with IP port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss 解決辦法

我在全球村發表於2024-08-07

最近在Mac上想要遠端一臺Linux伺服器,結果不知怎麼的就不能使用以前的ssh登入了

iot@ios-iMac ~ % ssh root@192.168.1.230                             

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

查了下,需要指定加密連線方式,結果如下:

 iot@ios-iMac ~ % ssh -oHostKeyAlgorithms=+ssh-dss root@192.168.1.230

The authenticity of host '192.168.1.230 (192.168.1.230)' can't be established.

DSA key fingerprint is SHA256:***********5+75ZypSQtVtGGJNbbA/6amkjEDA.

This key is not known by any other names

Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Warning: Permanently added '192.168.1.230' (DSA) to the list of known hosts.

root@192.168.1.230's password: 

Last login: Fri Jun 28 16:35:41 2024 from 192.168.9.16

這樣就可以連線成功了,但是那個引數複雜又不能自動不全,比較麻煩,不想每次都輸怎麼辦?

Mac上可以這樣處理:

 iot@ios-iMac ~ % sudo vim /etc/ssh/ssh_config

最後一行新增全域性變數:

    HostKeyAlgorithms +ssh-dss
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
#   UserKnownHostsFile ~/.ssh/known_hosts.d/%k
Host *
    SendEnv LANG LC_*
    HostKeyAlgorithms +ssh-dss

這樣操作以後就不用每次都帶那個引數了,可以像之前一樣使用簡單版的ssh root@IP了

其它平臺應該也是類似的,在ssh的配置檔案中新增全域性選項即可解決問題,我這個是Mac升級系統導致的。

對了,以上是在客戶端操作的!

相關文章