git pull over ssh gives wierd errors

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.

1
задан 25 November 2016 в 18:06
1 ответ

Запустив sh с sudo , вы эффективно используете корневой каталог .ssh учетные данные для доступа к репо. Они не совпадают с ключом, который вы сгенерировали и добавили в bitbucket.

Интересно, зачем вам вообще sudo , может ли репозиторий записываться только root? Одним из вариантов может быть добавление ssh-ключа root в bitbucket или отказ от использования sudo .

4
ответ дан 3 December 2019 в 17:36

Теги

Похожие вопросы