Git asking for password from command line

erich picture erich · Jan 19, 2011 · Viewed 11k times · Source

I setup git and gitosis on a server to manage my repos. It's working properly for the initial shell account I set it up with, i.e. I can run:

git clone git@MYSERVER:gitosis-admin.git

But when I try to use the separate accounts I've created (via gitosis.conf) it keeps asking for a password:

git clone johndoe@MYSERVER:gitosis-admin.git

I setup the SSH key and pushed a copy to the keydir on the server. This question seems to address the same problem, but the solution given is for tortoisegit.

Git keeps asking for password

How do I tell git to use the ssh key instead of asking for a password?

Answer

ebneter picture ebneter · Jan 19, 2011

You don't use your user name, you always say:

git clone git@MYSERVER:<repository>

Gitosis associates your name in its config file with the name of your key on the server. That is, you have lines like

[group users]
members = johndoe janeroe
writable = repo1 repo2

in gitosis.conf, and files johndoe.pub, janedoe.pub in gitosis-admin/keydir; gitosis will use the appropriate key for the user but you always use "git" as the user in the URL. That's because it's always using the "git" account.