Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git login with SourceTree fails, want to create login with SSH instead

I have serious problems signing in to SourceTree.

The login popup all the time when I use the program and the login must be re-entered.

I tried to solve this in several ways, including trying to switch from HTTPS to SSH, but I did not manage to fix SSH for SourceTree.

How can the failed login problem be resolved?

like image 970
user1564762 Avatar asked Oct 16 '25 09:10

user1564762


1 Answers

This guide goes step by step through how to set up SSH or changing the protocol from default HTTPS to SSH.

This fix the failed login problem.

In order for it to be possible to switch to SSH, it must first be set up.

Therefore, this is a guide for those who either have SourceTree login problems or need help with connect SourceTree to SSH.


Set up SSH key directory

  1. Create directory %UserProfile%/.ssh

Generating a new SSH key

To generate an SSH Key with SourceTree:

  1. Select "Tools" > "Create or Import SSH Keys"
  2. For "Number of bits in a generated key:" use '2048'
  3. Click "Generate"
  4. Move the mouse randomly until a key is generated
  5. A public key and a private key should be generated
  6. Click "Save public key" and save as .pub filetype in your .ssh folder
  7. Click "Save private key" and save as .ppk filetype in your .ssh folder
  8. Select "Conversations" > "Export OpenSSH key"

Folder should now contain:

  • id_rsa
  • id_rsa.pub
  • id_rsa.ppk

.ppk is the private key and .pub is the public key. The public key is stored on remote server, showing later for Bitbucket.


Add your public key in your remote server (e.g. Bitbucket).

  1. Login
  2. Select "Bitbucket settings"
  3. Select "SSH keys" > "Add key"
  4. Copy .pub key and paste into field

SSH key should look like this: Add SSH key


Add the SSH key to SourceTree

  1. Select "Tools" > "Options" > "General" > "SSH Client Configuration"
  2. Select OpenSSH for SSH Client
  3. Select "id_rsa" for SSH Key

Add the SSH key to the ssh-agent

  1. Click "Terminal" in SourceTree to start Git Bash tool from SourceTree
  2. Run the following:

    eval $(ssh-agent)

    The output should give you a process id back, something like, Agent pid 1234
    
  3. Run the following to add your generated private key "id_rsa":

    ssh-add ~/.ssh/id_rsa

    If successful, the output should say that an identity has been created.
    

Add SSH authentication in SourceTree

  1. Select "Tools" > "Options" > "Authentication">
  2. Select account and click Edit
  3. Change Preferred Protocol to "SSH" and Authentication to "Basic"
  4. Login with password
  5. Click OK

Test to clone a project with SSH key

  1. Select "File" > "Clone / New"
  2. Enter the url to the repository
  3. Add ssh://, after you’ve entered the complete url

    https://<your_username>@bitbucket.org/<account_name>/<repo_name>.git
    
    ssh://<your_username>@bitbucket.org/<account_name>/<repo_name>.git
    
  4. SourceTree will try to validate your input

  5. If everything went successfully you can now clone the repo
like image 161
user1564762 Avatar answered Oct 18 '25 03:10

user1564762