Sourcetree Generate Ssh Key Github

  1. Sourcetree Generate Ssh Key Github Windows 10
  2. Generating Ssh Key For Github
  3. Github Create Ssh Key Mac
  4. Add Ssh Key Github
  • Status:Needs Triage(View Workflow)
  • Resolution: Unresolved
  • Fix Version/s: None
  • Labels:
  • Environment:

First issue...

I set up a remote account to GitHub using OAuth and SSH. I created a new SSH key and enabled the checkbox to allow SourceTree to modify my SSH configuration.

Create a SSH key. If you don’t already have a SSH key for BitBucket and/or GitHub on the particular computer you’re using, you’ll need to create one for each service that you use and on each computer that you will use to access your repos: set up a SSH key for BitBucket on macOS (steps 1–2 for Git); create a SSH key for GitHub (step 1). Windows git SSH authentication to GitHub. Follow @vlad. If you don’t have a SSH public/private key pair you can generate it using the puttygen utility. Generating a new SSH key. Open Terminal Terminal Git Bash. Paste the text below, substituting in your GitHub email address. $ ssh-keygen -t rsa -b 4096 -C 'youremail@example.com' This creates a new ssh key, using the provided email as a label. Generating public/private rsa key pair.

When I attempted to Clone a repo, the clone window opened but there was an Error message of 'This is not a valid source path / URL'. Clicking on the message shows the connection log with the following.

/Users/USERNAME/.ssh/config: line 97: Bad configuration option: usekeychain
/Users/USERNAME/.ssh/config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.

Sourcetree generate ssh key github tutorial

I opened /Users/USERNAME/.ssh/config file and found the following new entry
# — SourceTree Generated ---
Host InsomniacSoftware-GitHub
HostName github.com
User InsomniacSoftware
PreferredAuthentications publickey
IdentityFile /Users/USERNAME/.ssh/InsomniacSoftware-GitHub
UseKeychain yes
AddKeysToAgent yes
# ----------------------------

Commented out the UseKeychain line and saved. Back in SourceTree, clicked on the Clone link and it successfully logged into GitHub.

After some testing, I discovered the error is due to using a non-Apple version of ssh that doesn't support the UseKeychain option. I have installed OpenSSH_7.5p1 (OpenSSL 1.0.2l 25 May 2017) via Homebrew at /usr/local/bin/ssh. This is the version SourceTree is using since it is the first in $PATH.

To make it work with either version of ssh, at the top of the ~/.ssh/config file, add the following lines

Sourcetree Generate Ssh Key Github Windows 10

Host *

IgnoreUnknown UseKeychain

This will cause non-Apple versions of ssh to ignore the UseKeychain option.

Second issue...

My system-wide ssh config file enables StrictHostKeyChecking by default (enforced by IT/Security department). SourceTree is unable to connect (Permission denied (publickey)) unless I create a 'Host github.com' entry in my personal ssh config file that disables StrictHostKeyChecking or points to a Known Hosts file that already contains github.com's public key.

Note: Adding these options to the SourceTree-Generated lines does not work as ssh isn't actually using those options (Host doesn't match, User should always be git, etc). SRCTREE-4631 discusses this a bit.

So that a user doesn't have to create a 'Host github.com' entry, SourceTree should always call git with the GIT_SSH_COMMAND variable setting these options, like this.

GIT_SSH_COMMAND='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o IdentityFile=/Users/USERNAME/.ssh/STGENERATEDKEY' git clone git@github.com ...

Now for the request.

When I was setting up the GitHub account, the SSH Key line was showing the default id_rsa.pub key. Clicking on the Copy To Clipboard button would bring up the Generate SSH Key dialog. The icon said to hold down Option key to generate a new key but the Generate SSH Key dialog would appear whether I was holding down Option or not, so it couldn't use my id_rsa key either. I generated a new SSH key which SourceTree saved as InsomniacSoftware-GitHub[.pub].

Github create ssh key mac

However, I already have a SSH key uploaded to GitHub that I'm using for other git applications, which is different from the default id_rsa.pub key. Unfortunately there is no way in the dialog window to tell SourceTree to select a different key.

Request: Allow the user to pick an existing key instead of forcing them to generate a new key.

Votes:
0Vote for this issue
Watchers:
2Start watching this issue

Objectives

Generating Ssh Key For Github

  • Explain what an SSH key is
  • Generate your own SSH key pair
  • Add your SSH key to your GitHub account
  • Learn how to use your SSH key in your GitHub workflow

Why Use an SSH Key?

When working with a GitHub repository, you'll often need to identify yourself to GitHub using your username and password. An SSH key is an alternate way to identify yourself that doesn't require you to enter you username and password every time.

SSH keys come in pairs, a public key that gets shared with services like GitHub, and a private key that is stored only on your computer. If the keys match, you're granted access.

The cryptography behind SSH keys ensures that no one can reverse engineer your private key from the public one.

Generating an SSH key pair

The first step in using SSH authorization with GitHub is to generate your own key pair.

You might already have an SSH key pair on your machine. You can check to see if one exists by moving to your .ssh directory and listing the contents.

If you see id_rsa.pub, you already have a key pair and don't need to create a new one.

If you don't see id_rsa.pub, use the following command to generate a new key pair. Make sure to replace your@email.com with your own email address.

(The -o option was added in 2014; if this command fails for you, just remove the -o and try again)

When asked where to save the new key, hit enter to accept the default location.

You will then be asked to provide an optional passphrase. This can be used to make your key even more secure, but for this lesson you can skip it by hitting enter twice.

When the key generation is complete, you should see the following confirmation:

The random art image is an alternate way to match keys but we won't be needing this.

Sourcetree generate ssh key github windows 10

Add your public key to GitHub

We now need to tell GitHub about your public key. Display the contents of your new public key file with cat:

Github Create Ssh Key Mac

The output should look something like this:

Copy the contents of the output to your clipboard.

Add Ssh Key Github

Login to github.com and bring up your account settings by clicking the tools icon.

Select SSH Keys from the side menu, then click the Add SSH key button.

Name your key something whatever you like, and paste the contents of your clipboard into the Key text box.

Finally, hit Add key to save. Enter your github password if prompted.

####Using Your SSH Key

Going forward, you can use the SSH clone URL when copying a repo to your local machine.

This will allow you to bypass entering your username and password for future GitHub commands.

Key Points

  • SSH is a secure alternative to username/password authorization
  • SSH keys are generated in public / private pairs. Your public key can be shared with others. The private keys stays on your machine only.
  • You can authorize with GitHub through SSH by sharing your public key with GitHub.