I am using EC2 and am new to the world of Linux, and I've looked for an answer to this but I think I'm just not sure how to ask the question correctly.

I have installed Jenkins and git using yum, under the account ec2-user, and they install fine. Yum created an account called jenkins which runs the Jenkins process (checked this using ps -aux and the user is jenkins).

I have a remote git repository that uses public/private keys. When I ssh-keygen, and then connect to my remote git repository through ec2-user, everything is fine. I'm just not certain how or where to create a key for the jenkins user.

This is where my trouble starts. When I su jenkins and then cd ~, I wind up in ~ec2-user. When I run ssh-keygen as jenkins, it wants to put the key into /home/ec2-user/.ssh/id_rsa - and that doesn't seem right.

How can I create a key pair for jenkins, or should I just have it added to the ~ec2-user/.ssh/id_rsa?


Don't use su jenkins, use su - jenkins. Then you should inherit the environment of the jenkins user, and key creation etc. should proceed painlessly.

| improve this answer | |
  • The prompt still shows me as ec2-user. Is that correct? – Triple Gilaman Feb 25 '13 at 18:10
  • Jenkins user will not have a shell set up by default (by design), which is why it's dropping immediately back to ec2-user. add -s /bin/bash to the su command to specify a shell. – J. Paulding Jun 4 '14 at 17:51
  • That is an excellent point; would you mind if I edited it into my answer? Or if you would prefer to do the edit, please do, and I'll approve it (though this is somewhat less reliable as I need a second user to approve it). – MadHatter Jun 5 '14 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.