简体   繁体   English

git pull over ssh给出错误

[英]git pull over ssh gives errors

This is my setup. 这是我的设置。

  1. My git repository is in bitbucket 我的git仓库在bitbucket中
  2. I have created keys on my remote aws ec2 server and kept it in ~/.ssh folder 我已经在远程AWS EC2服务器上创建了密钥,并将其保存在〜/ .ssh文件夹中
  3. I then add the key via the ssh-agent on my remote server 然后,我通过远程服务器上的ssh-agent添加密钥
  4. Updated these keys on the bitbucket website. 在bitbucket网站上更新了这些密钥。

When I login to my remote server and run "git pull" on my git repository everything works fine. 当我登录到远程服务器并在git存储库上运行“ git pull”时,一切正常。 No issues here. 这里没有问题。

But when I run the same the same via the cygwin bash on windows it gives me this error: 但是当我在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.

I do the following on my windows machine 我在Windows机器上执行以下操作

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

Where the "deploy.sh", cd's into my repository and does a git pull . 在“ deploy.sh”中, cd进入我的存储库并执行git pull

Why is this issue happening ? 为什么会发生此问题? Should I also keep these ssh keys on my windows machine? 我是否还应该将这些ssh密钥保留在Windows计算机上? Any help will be invaluable. 任何帮助都是无价的。

I was using "sudo" in 'sudo sh deploy.sh' which prompted it to check the creds in root users .ssh folder. 我在“ sudo sh deploy.sh 中使用“ sudo” ,这提示它检查root用户.ssh文件夹中的凭据。 Remove the "sudo" and it works fine. 删除“ sudo”,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM