I'm trying to run the following comamnd as user flc:
sudo hg clone git+ssh://email@example.com:flc/myproject.git /opt/flc/projects/myproject
However, I'm getting this error:
Permission denied (publickey).
I know I have the keys in /home/flc/.ssh and it works if I run the command below (note without sudo, but writing to /tmp so don't need sudo)
hg clone git+ssh://firstname.lastname@example.org:flc/myproject.git /tmp/flc/projects/myproject
The thing is I need sudo so it can write to /opt/flc/projects/myproject
So my question is how can I use sudo and still get it to find the .ssh keys in /home/flc/.ssh and hence work?