大网数据广告活动
服务器运维问答

git pull over ssh gives wierd errors

· 52CE 我爱测

This is my setup. My git repository is in bitbucket I have created keys on my remote aws ec2 server and kept it in ~/.ssh folder I then add the key via the ssh-agent on my remote server Updated these keys on the bitbucket website…

问题原文

原帖链接 · sp497 · CC BY-SA 3.0

This is my setup.

  1. My git repository is in bitbucket
  2. I have created keys on my remote aws ec2 server and kept it in ~/.ssh folder
  3. I then add the key via the ssh-agent on my remote server
  4. Updated these keys on the bitbucket website.

When I login to my remote server and run git pull on my git repository everything works fine. No issues here.

But when I run the same the same via the cygwin bash on windows it gives me this error:

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

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.

Why is this issue happening ? Should I also keep these ssh keys on my windows machine? Any help will be invaluable.

已采纳解答

原帖链接 · Michael · CC BY-SA 3.0

By running sh with sudo, you are effectively using the root's .ssh credentials to access the repo. Those do not match with the key you generated and added to bitbucket.

I wonder why you would need sudo in the first place, is the repo only writable by root? One option would be to add root's ssh key to bitbucket, or to refrain from using sudo.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。