Can someone point me in the direction I need look so I can configure my GIT client with the password needed for my private key? Every time I push and pull from my repository it asks me for the password for my key. I use command line and have the windows GIT client installed to use ssh.
Thanks for any pointers.
To connect to a Git repository with authentication over HTTP(S), every time it needs to set a username and password. You can configure Git to remember a username and password by storing them in a remote URL or by using Git credential helper.
I just had this problem here. My local git tree was corrupted, so I deleted it and cloned the project again from github. After that, it started to ask for my password on every pull or push. After some time, I realized I cloned the project with the HTTP URL (https://[email protected]/user/project.git). When I cloned again using the SSH URL ([email protected]:user/project.git), it stoped asking for the password.
Run git remote -v
. The output below is from a repository that clones via HTTPS: notice the https://
URL scheme.
origin https://github.com/git/git.git (fetch) origin https://github.com/git/git.git (push)
Clone URLs for SSH will have one of two forms:
[email protected]:foo/bar/baz.git
ssh://[email protected]/foo/bar/baz.git
Assuming your host supports both SSH and HTTPS (as GitHub, GitLab, and Gitorious do), then simply change the remote’s URL rather than recloning the entire history.
git remote set-url origin [email protected]:foo/bar/baz.git
Different hosts will have different URL designs. For example, switch the above GitHub URL from HTTPS to SSH with
git remote set-url [email protected]:git/git.git
GitHub has a related guide for changing a git remote’s URL.
On Windows, a typical setup uses PuTTY as the SSH client, which means you’ll want to run Pageant, PuTTY's SSH agent. On Windows, I run a quick batch job out of the Startup group:
@echo off
start /b "C:\Program Files\PuTTY\pageant.exe" "C:\Users\Greg\Greg.ppk"
where Greg.ppk
is a key that I created with PuTTYgen.
One more step: tell git to use plink, PuTTY's client for non-interactive connections. Set the environment variable GIT_SSH
to
C:\Program Files\PuTTY\plink.exe
assuming that's where PuTTY lives.
On Unix-like platforms, the fix is straightforward. If ssh-agent
isn't running, start it with, for example
$ eval `ssh-agent`
and then add your default identity with
$ ssh-add
If you have an identity somewhere else, run
$ ssh-add /path/to/other/ssh_id
If you're still having trouble, GitHub has a page for troubleshooting issues with GitHub and SSH, but please also update your question so we can make this a more helpful resource.
It may seem tempting to create and register an SSH key that has no password or passphrase because you won’t be prompted for it with each git clone
, git fetch
, git pull
, or git push
. However, with no passphrase, your SSH key is unencrypted. This means that anyone who is able to obtain a copy of your private key (the file named id_rsa
, id_dsa
, id_ecdsa
— without the .pub
extension) can impersonate you with no effort.
The nice design of SSH means that it is possible to make operations both convenient and secure. Go ahead and make your setup secure today. For a few minutes of extra effort now, you won’t have to wonder about it down the road.
If you’ve already set up a passwordless key, encrypt it by running
ssh-keygen -p
You will see prompts for the key file (with a default value), for your new passphrase, and again to confirm that you typed your passphrase correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With