一、背景
我在拉取gitlab代码的时候,报错
git clone git@192.168.10.250:root/xxx-service.git
Cloning into 'xxx-service'...
Unable to negotiate with 192.168.10.250 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
但是,我已经把本地的公钥添加到了gitlab ssh keys
另外本机是macbook pro m3,这是为什么呢?
二、解决办法
- 更新SSH客户端配置
你可以通过修改SSH客户端的配置文件来允许使用旧的密钥类型。在Mac上,SSH配置文件通常位于~/.ssh/config。
添加以下内容:
Host 192.168.5.250
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
在尝试连接之前,确保GitLab服务器的主机密钥是可信的。
你可以手动添加服务器的主机密钥到known_hosts文件中。
获取服务器的主机密钥:
ssh-keyscan -H 192.168.10.250 >> ~/.ssh/known_hosts