Issue
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?
Solution
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
- Create directory %UserProfile%/.ssh
Generating a new SSH key
To generate an SSH Key with SourceTree:
- Select "Tools" > "Create or Import SSH Keys"
- For "Number of bits in a generated key:" use '2048'
- Click "Generate"
- Move the mouse randomly until a key is generated
- A public key and a private key should be generated
- Click "Save public key" and save as .pub filetype in your .ssh folder
- Click "Save private key" and save as .ppk filetype in your .ssh folder
- 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).
- Login
- Select "Bitbucket settings"
- Select "SSH keys" > "Add key"
- Copy .pub key and paste into field
SSH key should look like this:
Add the SSH key to SourceTree
- Select "Tools" > "Options" > "General" > "SSH Client Configuration"
- Select OpenSSH for SSH Client
- Select "id_rsa" for SSH Key
Add the SSH key to the ssh-agent
- Click "Terminal" in SourceTree to start Git Bash tool from SourceTree
Run the following:
eval $(ssh-agent)
The output should give you a process id back, something like, Agent pid 1234
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
- Select "Tools" > "Options" > "Authentication">
- Select account and click Edit
- Change Preferred Protocol to "SSH" and Authentication to "Basic"
- Login with password
- Click OK
Test to clone a project with SSH key
- Select "File" > "Clone / New"
- Enter the url to the repository
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
SourceTree will try to validate your input
- If everything went successfully you can now clone the repo
Answered By - user1564762 Answer Checked By - Mary Flores (WPSolving Volunteer)