make git clone with sudo

When you run git using sudo, git will run as root. Because git is running as root, ssh is running as root. Because ssh is running as root, it is trying to log on to the remote server as root. The remote server is not okay with this (as it should be!)

You will need to do two things:

  • Put the username in your URL: ssh://[email protected]/soft.git.

  • Make your SSH key available to the root user, because it will look under /root/.ssh instead of /home/user/.ssh. (You could also probably point SSH at the correct key, but I don’t know how to do this, and SSH is picky about permissions.)

Leave a Comment