I was able to create a key and connect to github following these instructions via the command prompt successfully:
https://help.github.com/articles/generating-ssh-keys
However, when I try to connect via Sourcetree and putty I cannot. I've tried:
I also tried opening the key generated from the github command line instructions and it wanted me to convert it to a putty-type key which I did and saved off, tried with that one. Also no luck.
What am I doing wrong?
From Sourcetree, open the PuTTY Key Generator dialog by going to Tools > Create or Import SSH Keys. Click Load, navigate to your SSH folder, and click the private key. Make sure you're looking at All files if you don't see your private key. Enter your passphrase for the SSH key and click OK.
Make sure the authorized_keys file and the private key itself have the correct permissions and ownership. Check that key-based authentication is allowed by the server. Make sure the private key is readable by the SSH client. If you're using PuTTY, make sure your SSH keys are properly configured for the session.
In terminal enter this command with your ssh file name pbcopy < ~/. ssh/id_rsa. pub This will copy the file to your clipboard Now open you github account Go to Settings > SSH and GPG keys > New SSH key Enter title and paste the key from clipboard and save it. Voila you're done.
In order to get it worked I ended up going to Tools -> Options -> SSH Client and changing it to OpenSSH. I generated and uploaded several different types of keys trying to get it work as well but I think this is what finally did it.
In my case, I needed to switch to a git
or ssh
based repo path rather than the https
based repo path. This causes SourceTree to switch to SSH based authentication.
This setting can be found at Repository => Repository setting => Paths
Example:
Correct repo paths
[email protected]:<username>/<reponame>.git
or
ssh://[email protected]/<username>/<reponame>.git
(Note: if you are working with a repo that isn't yours, replace username
with organization name
)
Wrong repo path
https://github.com/<username>/<reponame>.git
HTTPS repo paths result in SourceTree trying to be extra smart and failing spectacularly. You get prompted for a username/password GUI dialog which will never work if you have 2 factor authentication enabled.
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