Managing Git Users and Passwords
I’ve been using Git to keep a repository of a project on a separate server. Currently to push things to the repository after a commit I do
and then I am asked for the password for the account I used to setup the git repository on the remote server. Since it’s been awhile since I setup the repository, I’m not sure how to either remove that password (bad idea maybe) or change/add user accounts for the git repository. I’m sure it’s something simple but I’m having a hard time googling for it. Is there some argument I’m missing for the push command?
- How to change git ssh user for a remote push temporarily?
- Run Jenkins jobs on Linux under a User
- Git Change User
- SVN change username
- git -permission denied(403)
- Ever need to parse the svn log for files committed by a particular user since a certain date?
One Solution collect form web for “Managing Git Users and Passwords”
There’s likely some duplicates here on SO, but I didn’t see them at first search, so here’s your quick answer.
You probably want to use SSH public/private keypair authentication. In general, this means running
ssh-keygen on your local computer (if you haven’t before), and then using
ssh-copy-id user@host to copy your public key to the remote. (If you don’t have
ssh-copy-id, you can just add your public key to
.ssh/authorized_keys on the remote; that’s all it does.) Be sure to give the public key to the appropriate user (the one with permissions for the git repo).
If you’d like to be more secure, you can give your keypair a passphrase and use something like ssh-agent or keychain to remember it for a session. See Configuring Git over SSH for more information on that.
If you’re going to be doing a lot of this, you might want to look into gitolite, which automates a lot of this git admin type stuff. If you’re going to keep doing it manually, and give others the ability to use that repo, you might want to make the repo user’s shell
git-shell, which is essentially a no-login shell which is only able to run the necessary git commands.