0

Background: I am trying to write a jenkins job which deploys a rails app using capistrano. As part of this, I need to add the ssh key which I have copied to the jenkins user's .ssh folder on that environment. I have correctly set the owner, group and permissions for both id_rsa and id_rsa.pub in that folder.

I am receiving the error Net::SSH::AuthenticationFailed: Authentication failed for user deploy@[server]. Upon investigation, the following happens when I run the following commands as the jenkins user:

ssh-add ~/.ssh/id_rsa

so far so good.

But the public key at ~/.ssh/id_rsa.pub is not the one returned by ssh-add -L

If I follow the same steps on my local machine, the correct key is added and I am able to ssh into the environment.

Why does ssh-add seem to add the wrong key (which I can't seem to find anywhere else on the system)?

eikumbokum
  • 41
  • 8

1 Answers1

0

When you run ssh-add -L on jenkins server you're probably seeing public key forwarded from your own machine via the "ssh agent forwarding" mechanism.

Try sshing to your jenkins server with the -a flag to disable ssh agent forwarding:

ssh -a <jenkins_server>