一台服务器配置多个git账号的ssh的keys

需求是这样,原来服务器的默认的key被其他同事添加到他的gitlab账号中了,我就没法用这个keys,服务器没法拉去代码。

所以需要再生成一个我自己用的key。

ssh-keygen -t rsa -b 4096 -C "[email protected]"

Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] 

 注意输入文件名是别默认回车,改成自己的路径就行了。

比如说:/Users/you/.ssh/id_rsa_a

然后启动ssh-agent,否则可能会报错:Could not open a connection to your authentication agent.

eval $(ssh-agent -s)

添加我们生成的key到ssh-agent中:

ssh-add /Users/you/.ssh/id_rsa_a

通过ssh-add -l命令检查一下看是否添加成功:

4096 SHA256:6WJ84Sd+JVvS0gO8ngwcQ4rxZyiIWVJ56QLD+I/yaUc [email protected] (RSA)

添加成功。

然后在把这个key添加到gitlab账户中,就可以拉去代码了。 

你可能感兴趣的:(Ubuntu,算法)