I've got Git for Windows (configured for MinTTY and PuTTY\plink.exe
) and PuTTY installed, and I am trying to get it to work with a Bitbucket repository. I've got my SSH key loaded, in Pageant and on the website, and yet whenever I attempt to do anything that requires pulling/pushing:
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
When I run the suggested ssh -v [email protected]
it uses id_rsa
but none of my other keys in ~/.ssh
. Trying to use ssh-add ~/.ssh/bitbucket_rsa
results in:
Could not open a connection to your authentication agent.
I've read about configuring PuTTY to allow forwarding, but that's usually where the advice ends, so I just set this option for the default session and saved it there.
I've run ps
to check which applications were running, and ssh-agent
was not among them. Running eval 'ssh-agent'
starts the daemon, but it makes no difference.
Make sure the "Quick Edit Mode" option is checked. If an "Experimental" tab shows up, select it and then make sure the top "Enable experimental console" and the "Enable new Ctrl key shortcuts" options are both checked. Click 'OK' to save. Now you can use Ctrl+V to paste.
The default location is: %HOMEDRIVE%%HOMEPATH%\. ssh\id_rsa. pub . That would expand to something like C:\Users\dennis\.
This is what ended up working for me.
BTW, I do have Bash on Windows as well, but I don't think that matters.
I had Sourcetree installed and pointed at its folder with plink.exe
, puttygen.exe
, & pageant.exe
. You could also download and install these separately as well.
Environment
into your Windows 10 search bar. Otherwise, open up System Properties / Advanced System Settings and find your Environment Variables.plink.exe
file (you may also have pageant.exe
and puttygen.exe
in the same folder). Mine was: C:\Program Files (x86)\Atlassian\SourceTree\tools\putty\plink.exe
Note: Newer versions of Sourcetree seem to install ot %localappdata%
. The tools are located at %localappdata%\SourceTree\app-x.x.x\tools\putty
Note: The newer Sourcetree (v2 on Windows) uses versioned directories, so every time you update it, you'll have to update this which is a pain. It is best to just make a copy of plink.exe
and put it somewhere that's not going to change.
If you have any of the above programs running you can always open up task manager, find the process, and open up the folder location to get the path to plink.exe
.
Make sure to restart your terminals so that they get the updated environment variables. For me, I was running Bash for my integrated terminal within Visual Studio Code, so I had to restart Visual Studio Code. It would have surely been acceptable to close the integrated terminal and open a new one, but I also wanted the built in git functionality in Visual Studio Code to work as well.
Given that I have Sourcetree installed I was able to use its interface to clone down out of Bitbucket and push through its interface, but trying through terminals was not working, because they were using a different credential set.
Another interesting thing to point out is that if you navigate into your project's git configuration located at: ./.git/config
, you could swap out your remote from using SSH to HTTPS. You can grab the following values from your Overview on your Bitbucket repository.
[email protected]:USERNAME/REPO_NAME.git
https://[email protected]/USERNAME/REPO_NAME.git
I noticed while using HTTPS on Windows 10 it then will use the Windows Credential Manager (I tried adding my credentials to it while trying to figure this out myself, but I was still using SSH so it didn't matter) When you go to interact with the remote repository it will prompt you for your credentials and store them for later use in Windows Credential Manager :)
Hopefully one of these methods will work out for you. The HTTPS method will skip the whole SSH key generation and pushing it up into Bitbucket, but it feels more secure and portable for me.
You may need to add your key to the keychain especially if you're using Visual Studio Code and have a passphrase on your key (currently Visual Studio Code will not allow you to type in a passphrase).
ssh-add -K ~/.ssh/id_rsa
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#adding-your-ssh-key-to-the-ssh-agent
I'm not sure if these may be helpful for someone, but I've been following getting SSH support into Visual Studio Code for Windows: https://github.com/Microsoft/vscode/issues/13680.
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