Uploaded image for project: 'Sourcetree For Mac'
  1. Sourcetree For Mac
  2. SRCTREE-4836

SSH config issues and SSH key request

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Medium Medium
    • None
    • 2.5.3
    • None
    • None
    • macOS 10.12.5

      SourceTree 2.5.0 - 2.5.3

       

    • Severity 2 - Major

      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.

      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.

      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

      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].

      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.

       

              Unassigned Unassigned
              1ae1dc18f35f Insomniac Software
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: