在有多个git平台的时候就需要多个公钥,不然新的会把老得覆盖。
在用自己命名一个新的公钥
ssh-keygen -t rsa -C "你的邮箱" -f ~/.ssh/起个文件名
生成多个公钥,在不同git平台上面使用不同的公钥。
起个新的名字之后
在.ssh/目录下面新建config文件编辑内容增加
Host github.com
HostName github.com
User suyunxue
PreferredAuthentications publickey
IdentityFile ~/.ssh/github
然后提交代码如果报错
Bad owner or permissions on /home/username/.ssh/config
fatal: Could not read from remote repository.
说明config没有可读权限,执行
sudo chmod 600 config
这样再去提交代码就可以了。
然后如果新增别的平台,比如gitlab就可以在config里面增加,然后制定不同平台使用不同的公钥。

882

被折叠的 条评论
为什么被折叠?



