1

I have my repo hooked up to Codeship which runs tests and then finally runs a script on my server via SSH:

ssh deploy@my.server '/var/www/deploy-script.sh'

On my server I have my deploy user set up. I have that user's public key stored on my github account. I also have the codeship public key for my project stored in ~/.ssh/authorized_keys.

Inside deploy-script.sh, I'm navigating to the repo directory and then trying git pull. Obviously, I need the latest code to be pulled down without a password as this is being run on a virtual machine on codeship. Codeship is apparently able to SSH into my server and run the deployment script, however the log is reporting:

> Pull updates from Github.
Permission denied (publickey).
fatal: Could not read from remote repository.

If I log into my server as the deploy user and run the script fine, with the git pull working correctly.

What am I missing? Why doesn't github allow access when it's codeship logging in as the deploy user rather than me?

Snowman
  • 1,160
  • 1
  • 8
  • 24

1 Answers1

1

It seems I overlooked that ssh-agent was not persisting between login sessions, so the next time I logged in as the deploy user I also got the permission denied error. I had to ssh-add again before my identity was added and I could pull from github. In order to make it persist, I followed the instructions here: Add private key permanently with ssh-add on Ubuntu

Added the following to ~/.ssh/config:

IdentityFile ~/.ssh/deploy-key
Community
  • 1
  • 1
Snowman
  • 1,160
  • 1
  • 8
  • 24