Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to execute a command which requires root privileges so I use sudo.

sudo puppet apply /etc/puppet/manifests/site.pp

This command involves cloning a private github repo with ssh. The only way this works is if I add my ssh to the root user.

I don't want to add my ssh to root user. How can I use sudo but still use the ssh key for the ubuntu user?

share|improve this question

2 Answers 2

I found this answer over on Server Fault. Essentially, you need to add this line to /etc/sudoers (use visudo):

Defaults    env_keep+=SSH_AUTH_SOCK

You should then be able to runt your command normally:

sudo puppet apply /etc/puppet/manifests/site.pp
share|improve this answer
    
This doesn't work for me. –  jamjam Feb 23 '13 at 15:49
    
@jamjam Try sudo -E and also try some of the other solutions on the linked answer. –  terdon Feb 23 '13 at 15:56

It turn's out there was a pretty simple solution to this.

Adding a -u option allows me to specify a user.

sudo -u ubuntu puppet apply /etc/puppet/manifests/site.pp

Now the ssh key for that user will be used.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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