git SSH操作(配置多个密钥对应多个网站)

Unable to negotiate with xxx.xxx.xxx.xxx port 8080: no matching host key type found. Their offer: ssh-rsa
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

出现这个报错一般都是需要配置一下host和加密方式
具体配置如下:

Host xxxxxx
HostName xxxx
User  xxxx
Port xxx 
IdentityFile ~/.ssh/id_rsa   
HostKeyAlgorithms ssh-rsa
PubkeyAcceptedKeyTypes ssh-rsa

这个配置可以多个端口配置
也可以只配置 host *

MAC升级到 macOS Ventura后也会报这个错误
需要 touch一个config文件在~/.ssh目录下

cd ~/.ssh
touch config

然后进入目录,复制以下内容到文件中


最终试验可行

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/newed/id_ed25519

Host gitcode.net
  Port XXX
  AddKeysToAgent yes
  UseKeychain yes
  HostKeyAlgorithms ssh-rsa
  PubkeyAcceptedKeyTypes ssh-rsa
  IdentityFile ~/.ssh/id_rsa

git SSH 常规操作文档:
https://gitcode.net/gitcode/help-docs/-/wikis/docs/ssh#common-steps-for-generating-an-ssh-key-pair

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容