管理Git生成多个ssh key及报错Bad configuration option解决方法-2018-10-06

如题所述

第1个回答  2022-06-16
生成两个key

生成两个key后,添加到对应服务器的 ssh kyes管理设置 中。

本地添加私钥

本地添加私钥名命令ssh-add ~/.ssh/Your Key Name,如果出现“Could not open a connection to your authentication agent”的问题,可以执行命令ssh-agent bash,再运行添加命令。另外,可用通过

3.一点说明

以上的我采用的是oschina的码云和github的两种kye的结合体,其中每段最后的IdentityFile跟着是你自己ssh key的名字,不要搞错了。

最后就是测试咯

oschina的测试方法ssh -T [email protected];成功收到的回复为“Welcome to Git@OSC,‘Your Name’ ”

github的测试方法ssh -T [email protected];成功收到的回复为”Hi ’Your Name‘ ! You’ve successfully authenticated, but GitHub does not provide shell access.“

借鉴文章

git 配置多个SSH-Key

管理git生成的多个ssh key

---------------------本文来自 来不及解释了快上车 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/u012365926/article/details/52293036?utm_source=copy

这是我修改配置文件时的操作:

1.在~/.ssh目录下新建一个config的文件

2.添加以下内容

结果出现报错:

问题原因

~/.ssh/config文件缩进有问题

解决方案

检查该配置文件,把每一行配置前的空格都去掉

需要注意的是,如果config文件中只配置一个host对应的账号的话,缩进是无所谓的,都可以正常使用。但是有多个配置的话,配在后面的账号就会受影响。所以都修改一下,不要有空格。

---------------------本文来自 庭然 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/lili625/article/details/77833684?utm_source=copy

附我~/.ssh/config文件修改好后的例子:

3.添加私钥时发生如下错误

输出错误: Could not open a connection to your authentication agent

解决此问题的方法是执行下

然后再次执行ssh-add ~/.ssh/id_rsa就可以顺利执行了

http://outofmemory.cn/code-snippet/37443/git-ssh-add-.ssh-id_rsa-Could-not-open-a-connection-to-your-authentication-agent