这是我的设置。
~/.ssh文件夹中 当我login到我的远程服务器,并运行git pull我的git存储库一切工作正常。 这里没有问题。
但是当我通过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机器上? 任何帮助将是非常宝贵的。
通过使用sudo运行sh ,您正在有效地使用root的.ssh凭据访问回购。 这些与您生成的并添加到bitbucket的密钥不匹配。
我想知道你为什么需要sudo ,是否只能由root用户写回? 一个select是将root的ssh密钥添加到bitbucket,或者避免使用sudo 。