-1

I can not make sourcetree work with the ssh key that i have in my yubikey. Does anybody know how can i fix it?

Thank you.

P.D: I have tried different recommendations that i found on the internet, but they have not worked. I get to connect for example to github using ssh on terminal and works fine, but Sourcetree does not work.

I'm working on macOS Mojave

This the configuration that Sourcetree put inside .ssh/config

# --- Sourcetree Generated ---
Host *******-GitHub
    HostName github.com
    User ******
    PreferredAuthentications publickey
    IdentityFile /Users/*******/.ssh/GitHub
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

# --- Sourcetree Generated ---
Host ******-GitLab
    HostName GitLab
    User *******
    PreferredAuthentications publickey
    IdentityFile /Users/******/.ssh/GitLab
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

I have tried to delete this file but it does not work.

I have also tried to modify the keys that refer to the IdentityFile by putting the (Yubikey) public key inside but nothing.

Finally I have modified the github and gitlab accounts that I have associated with sourcetree so that the same program will not generate a ssh key but it does not work either because it does not recognize the ssh private key of the yubikey.

The strange thing is that if the connection is made from terminal using ssh git@github.com it works perfectly.

thewolfx41
  • 11
  • 5

1 Answers1

1

At the moment there is no definitive solution since atlassian has not released an update that corrects this problem.

The problem lies in how Macos manipulates applications with GUI, since they can not read the information of shell environment variables like SSH_AUTH_SOCK.

A possible solution that I have found that can be applied to both sourcetree and cyberduck program is to launch the application directly from the shell of the system so that it can read these variables.

To avoid having to always open the applications using the terminal, it is best to create an exec file recognized by macos in which we will introduce the following:

#!/bin/bash
/Applications/Sourcetree.app/Contents/MacOS/Sourcetree &
exit 0

Finally, we apply the 744 permissions so that macos will recognize it as an exec shell file.

chmod 744 open_source_tree

OBSERVATION: to not have the shell open once we are spoken sourcetree (for example) we have to modify the configuration of the shell to be closed after an exit. In this stackoverflow thread explain how to do it https://stackoverflow.com/questions/5560167.

In this way we can create icons on the desktop that open the GUI applications through the terminal (on the background) and that these applications can use gpg-agent as ssh agent to use the yubikey with an authentication key.

thewolfx41
  • 11
  • 5