I need to use sudoto run my program:
sudo ./my_program
I am trying to run git clonefrom my program, but instead I am trying to use SSH keys for the root user. Is there a way to execute this single command as the user who originally called my program?
I think I can do:
su - original_user -c "git --version"
But how can I determine the username of the original user? Or is there another elegant solution?
source
share