最近在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.230The 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 namesAre you sure you want to continue connecting (yes/no/[fingerprint])? yesWarning: 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/%kHost * SendEnv LANG LC_* HostKeyAlgorithms +ssh-dss
这样操作以后就不用每次都带那个参数了,可以像之前一样使用简单版的ssh root@IP了
其它平台应该也是类似的,在ssh的配置文件中添加全局选项即可解决问题,我这个是Mac升级系统导致的。
对了,以上是在客户端操作的!