i have ssh-agent setup for the user www-data and the password saved for the private key
from root i need to run "sudo -u www-data git pull" so it doesn't ask for the git private key password. sudo doesn't run the .bashrc script so not sure how to pull this off?
any suggestions?
I do this, and do an ssh-add as part of my .bash_profile:
sudo -u otherusername ssh-agent bash -l
Unfortunately, I don't seem to have any history when I use the up-arrow when doing this. I do, however, when I run the same command minus the sudo part.
By the way, this is what I have in my bash profile to auto-start ssh-agent (only once) and add an RSA key (only once):
# Start ssh-agent & add key
if [[ -z $SSH_AGENT_PID ]];
then
echo Starting ssh-agent automatically...
ssh-agent bash -l
elif [[ 0 == `ssh-add -l | grep "(RSA)" -c` ]];
then
echo Adding ssh key automatically...
# you might have your key in a different location:
ssh-add ~/.ssh/idents/id_rsa
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With