When I log in to my server via SSH, I am able to use git over ssh (private repository):
user@local:~$ ssh example.com Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 2.6.32-042stab083.2 i686) * Documentation: https://help.ubuntu.com/ Last login: Thu Oct 30 10:46:22 2014 from 18.104.22.168 user@remote:~$ cd ~/path/to/project/ user@remote:~/path/to/project$ git pull Enter passphrase for key '/home/user/.ssh/id_rsa': Already up-to-date. user@remote:~/path/to/project$ ps -aux | grep ssh-agent user 450 0.0 0.0 4396 832 pts/4 S+ 10:57 0:00 grep ssh-agent user 32680 0.0 0.0 4168 696 ? Ss 10:50 0:00 ssh-agent user@remote:~/path/to/project$
Note however, that I must enter the passphrase, even though in a separate session, I added the key using
ssh-add to ssh-agent. Ssh-agent is still running, as shown above. I assumed this would let me use the ssh key without entering the passphrase again. I was wrong.
Since I'm using a deployment script that involved cloning or pulling the repo (depends on the project), I run it from the CI server like this:
ssh email@example.com '~/path/to/deployment/script.sh'
As a result, I get a "Permission denied (publickey)." error, since the key needs to be unlocked using a passphrase and none is given.
Are there ways around this besides creating an ssh key without a passphrase?