我从mac终端克隆现有的github repo到我的本地,我没有问题就拉了几次。我修改了一些代码然后添加。并且承诺,现在我无法拉动或推动而没有获得"权限被拒绝(公钥)。"我尝试过使用ssh和https,但是有很多关于如何解决这个问题的信息,但似乎没有什么对我有用,这让我发疯了。
当我输入ssh -vT git@github.com
时我明白了:
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to github.com [....ip....] port 22.
debug1: Connection established.
debug1: identity file /Users/macbookpro/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
我的id_rsa实际上是在路径中:
/Users/macbookpro/Documents/pub_key/id_rsa
如果这是问题,我该如何更新路径?
自从克隆回购邮件以来,我不能只输入git pull吗?
答案 0 :(得分:2)
将ssh键移动到~/.ssh
文件夹
另一种选择是使用以下内容创建.ssh/config
文件:
Host name github.com
HostName github.com
IdentityFile /Users/macbookpro/Documents/pub_key/id_rsa
User <username>
或者只需将密钥添加到ssh-agent:
ssh-add /Users/macbookpro/Documents/pub_key/id_rsa
eval $(ssh-agent)