3

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

git push

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?

Thanks.

Anon
  • 5,103
  • 11
  • 45
  • 58

1 Answers1

5

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.

Community
  • 1
  • 1
Cascabel
  • 479,068
  • 72
  • 370
  • 318