git pull over ssh会出错

时间:2016-11-25 13:04:08

标签: git ssh bitbucket

这是我的设置。

  1. 我的git存储库位于bitbucket
  2. 我在远程aws ec2服务器上创建了密钥并将其保存在〜/ .ssh 文件夹中
  3. 然后我通过远程服务器上的ssh-agent添加密钥
  4. 在bitbucket网站上更新了这些密钥。
  5. 当我登录到我的远程服务器并在我的git存储库上运行“git pull”时,一切正常。 此处没有问题。

    但是当我通过windows上的cygwin bash运行相同的内容时,它会给我这个错误:

    Permission denied (publickey).
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    

    我在Windows机器上执行以下操作

    ssh -i xyz.pem user@ip -t 'sudo sh deploy.sh'
    

    将“deploy.sh”, cd 放入我的存储库并执行git pull

    为什么会出现这个问题? 我是否应该将这些ssh密钥保存在我的Windows机器上? 任何帮助都是非常宝贵的。

1 个答案:

答案 0 :(得分:0)

我在'sudo sh deploy.sh'中使用“sudo”,这促使它检查root用户.ssh文件夹中的信用。删除“sudo”,它工作正常。