Permission to xxx denied to otherUser

这是因为你没有权限

解决方案

1.生成一对新的SSH KEY

cd ~/.ssh

ssh-keygen -t rsa -C "邮箱地址"

然后会提示你输入文件名和密码,文件一般会这么写:id_rsa_personal,personal 部分区你容易记忆的

然后.ssh目录下就会多出来两个文件(一对RSA),私匙(id_rsapersonal),公匙(id_rsapersonal.pub)

2.将公匙文件里面的内容添加到 git 账号下

github登录

头像下 settings

选择 SSH and GPG keys

选择 New SSH key

key中黏贴(title 随便)

3.配置 config 文件

eg:

#Default GitHub
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa

Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal

这里 Host 和 IdentityFile 需要做些修改

Host 与远程服务器的 Host 对应

eg:

git@github-personal:tom/index.git
github-personal.com:tom/index.git

IdentityFile就是私钥

4.修改 origin

到 clone 文件夹下修改 origin 为 A 或 B

A: git@github-personal:tom/index.git
B: github-personal.com:tom/index.git

5.连接下试试

ssh -T github-personal

得到下面提示说明设置成功了

Hi tom You've successfully authenticated, but GitHub does not provide shell access.

github账户如果还是显示之前id_rsa密钥账户的话请把你的密钥加入sshAgent代理中

ssh-add id_rsa_personal

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容