SourceTree not able to push via SSH

RetroVertigo December 24, 2018

I changed my password (per Atlassian email) for Bitbucket, and now my source tree cannot push code to repo.  I create a SSH key, but it is for read-only and I cannot push my commits.  Anyone else run into this?  Any suggestions?

3 answers

0 votes
RetroVertigo December 28, 2018

OK, so this is not really an answer, as I was never able to get this to work.  I just copied my code into a new folder location and created a new repo and was able to push to that to BitBucket.  I still have no idea why my original repo won't push.

0 votes
RetroVertigo December 26, 2018

Hey Stephen, thank you for the reply.

  I have deleted the password file from Windows, and working on cleaning out the preferences for Source Tree.  I was trying to work on SSH only authentication, per Atlassian recommendation, but the only thing I could setup was a read-only key.  Not sure, what the issue was on my end, but I am still getting an error when trying to push, that states this: repository access denied. access via a deployment key is read-only. 

Which, make sense as I loaded the SSH key as read-only on BitBucket(as there was no where else I knew to load, per Atlassian documentation).  I hope that clearing out the preferences removes the SSH route, but I am not sure and wanted to post this in the interim while I work on it.

 

Also, I update the URL from HTTPS to SSH, per this walk through, so that might be an issue on my side as well:  https://confluence.atlassian.com/bitbucket/change-the-remote-url-to-your-repository-794212774.html

 

Thanks again for all the info, and let me know if there are any additional steps I need to look out on the config side for removing the SSH read-only key, piece.

 

thanks

Travis

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 26, 2018

Hello Travis,

Changing your password within Bitbucket can cause this issue within Sourcetree due to cached credentials. There are a few options to resolve this issue (depending on the OS you’re using)

Ensure Sourcetree is closed prior to completing these steps.

Windows:

  1. Remove your password file from Sourcetree temp
    1. C:\Users\<username>\AppData\Local\Atlassian\SourceTree\
  2. Check if you’re using the Git-credential manager for windows
    1. https://github.com/Microsoft/Git-Credential-Manager-for-Windows
    2. https://github.com/Microsoft/Git-Credential-Manager-for-Windows/blob/master/Docs/CredentialManager.md

Mac OS:

  1. Remove your password file from Sourcetree application
    1. ~/Library/Application Support/SourceTree/

Additionally, if this does not work you may need to clear out your Sourcetree preferences to resolve the issue. You may find further information about this at How to Wipe SourceTree Preferences.

I hope this helps to give guidance on how to resolve your credential issue. If you’re still having an issue after these steps, please let us know.

Regards,
Stephen Sifers

Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 26, 2018

Hello again Travis,

The SSH key which you added to Bitbucket, was it within your profile settings or within a specific repository?

The error you’re getting may also be related to Bitbucket no having your public key or your SSH agent does not have your SSH key. You can see additional troubleshooting steps for this at Troubleshoot SSH issues

Additionally, there is a stackoverflow thread similar to the new error you are having, you may find that thread at https://stackoverflow.com/questions/13306435/repository-access-denied-access-via-a-deployment-key-is-read-only

Please do let us know the outcome of the preference clean-out along with any SSH rekeying you end up doing.

Regards,
Stephen Sifers

RetroVertigo December 26, 2018

EDIT: I just saw your reply, so mine is a little out of whack with yours.  I did try the clean and it did not help with the error, so see below on what I did.

 

Hey Stephen

  I apologize, as I wrote my reply within the suggested answer area. 

So, I tried everything you had written down, but my SourceTree was still routing through the SSH read only keys, so I reversed what I had on my URL, from SSH to HTTPS, but I still am getting errors. 

  The error I am getting is that either, the URL is incorrect, or if I put in a certain URL, the push acts like it goes through, but all my commits are still within Source Tree.  Here is the error I am getting:

 

fatal: HttpRequestException encountered.
   An error occurred while sending the request.

fatal: HttpRequestException encountered.
   An error occurred while sending the request.

Pushing to https://<username>@bitbucket.org/<userName>/<repo name>.git
To https://bitbucket.org/<UserName>/<Repo Name>.git
 = [up to date]      masterlaptop -> master
updating local tracking ref 'refs/remotes/origin/master'
Everything up-to-date

 

So, I might have the URL for the Repo, incorrect, but I am not sure.  Again, any suggestion or help is greatly appreciated.

 

Thanks

Travis

Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 26, 2018

Hello Travis,

No worries on the replies or edits.

Lets start with removing and re-creating your SSH key (On both ends, Bitbucket and Sourcetree/SSH agent).

From there, lets run back through the SSH setup for Sourcetree on Windows: Set up SSH with Sourcetree on Windows. Ensure your SSH key is added to your Bitbucket settings and not a repository.

Something along the way is getting cached or has not been cleared out. Once you run back through the SSH setup, please let us know if the same error is still present.

Regards,
Stephen Sifers

RetroVertigo December 26, 2018

Thanks Stephen

  So, I am running through the setup for SSH again, but I did run into an issue (which the Stack Overflow person ran into as well), but I am not sure on how to proceed with the Private SSH Key.  When I go into SSH Keys on the Bitbucket settings, it is asking for both Public and Private.  When I did this last time, I just opened the Private key in NotePad++ and copied the Private key section and pasted that in.  Is this correct?  Let me know if I am getting something wrong on that. 

  I will continue with the setup and post an update.

 

thanks

Travis

RetroVertigo December 26, 2018

EDIT: For additional information

EDIT2: Added Log

 

OK, I redid my SSH keys and I am getting the same message as last time.  Can you confirm what you mean by delete SSH Agent/SourceTree SSH Keys?  Is there anything I need to delete within Windows for the SSH piece for SourceTree?  I have removed the Key from Paegent, but other than that I have not changed anything. 

  Also, Can you confirm what the URL needs to be for the Repo?  Is it https://<your_username>@Bitbucket.org/<account_name>/<repo_name>.git  ?  Also, can you tell me what the difference on my Username vs Account Name is?  I am not sure which is which, or if they are the same.

 

Upon working on the SSH Troubleshooting it seems that I am able to connect to BitBucket but the Public Key fails.  I am not sure why, as I am loading it into BitBucket, per the StackOverflow thread you cited. 

 

OpenSSH_7.9p1, OpenSSL 1.1.1a  20 Nov 2018                                             
debug1: Reading configuration data /etc/ssh/ssh_config                                 
debug1: Connecting to bitbucket.org [****] port 22.               
debug1: Connection established.                                                        
debug1: identity file /c/Users/TravLaptop/.ssh/id_rsa type -1                          
debug1: identity file /c/Users/TravLaptop/.ssh/id_rsa-cert type -1                     
debug1: identity file /c/Users/TravLaptop/.ssh/id_dsa type -1                          
debug1: identity file /c/Users/TravLaptop/.ssh/id_dsa-cert type -1                     
debug1: identity file /c/Users/TravLaptop/.ssh/id_ecdsa type -1                        
debug1: identity file /c/Users/TravLaptop/.ssh/id_ecdsa-cert type -1                   
debug1: identity file /c/Users/TravLaptop/.ssh/id_ed25519 type -1                      
debug1: identity file /c/Users/TravLaptop/.ssh/id_ed25519-cert type -1                 
debug1: identity file /c/Users/TravLaptop/.ssh/id_xmss type -1                         
debug1: identity file /c/Users/TravLaptop/.ssh/id_xmss-cert type -1                    
debug1: Local version string SSH-2.0-OpenSSH_7.9                                       
debug1: Remote protocol version 2.0, remote software version conker_1.1.17-9953920 app-
152                                                                                    
debug1: no match: conker_1.1.17-9953920 app-152                                        
debug1: Authenticating to bitbucket.org:22 as 'git'                                    
debug1: SSH2_MSG_KEXINIT sent                                                          
debug1: SSH2_MSG_KEXINIT received                                                      
debug1: kex: algorithm: curve25519-sha256@libssh.org                                   
debug1: kex: host key algorithm: ssh-rsa                                               
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC:  compr
ession: none                                                                           
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC:  compr
ession: none                                                                           
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY                                              
debug1: Server host key: ssh-rsa SHA256:******    
debug1: Host 'bitbucket.org' is known and matches the RSA host key.                    
debug1: Found key in /c/Users/TravLaptop/.ssh/known_hosts:1                            
debug1: rekey after 134217728 blocks                                                   
debug1: SSH2_MSG_NEWKEYS sent                                                          
debug1: expecting SSH2_MSG_NEWKEYS                                                     
debug1: SSH2_MSG_NEWKEYS received                                                      
debug1: rekey after 134217728 blocks                                                   
debug1: Will attempt key: /c/Users/TravLaptop/.ssh/id_rsa                              
debug1: Will attempt key: /c/Users/TravLaptop/.ssh/id_dsa                              
debug1: Will attempt key: /c/Users/TravLaptop/.ssh/id_ecdsa                            
debug1: Will attempt key: /c/Users/TravLaptop/.ssh/id_ed25519                          
debug1: Will attempt key: /c/Users/TravLaptop/.ssh/id_xmss                             
debug1: SSH2_MSG_SERVICE_ACCEPT received                                               
debug1: Authentications that can continue: publickey                                   
debug1: Next authentication method: publickey                                          
debug1: Trying private key: /c/Users/TravLaptop/.ssh/id_rsa                            
debug1: Trying private key: /c/Users/TravLaptop/.ssh/id_dsa                            
debug1: Trying private key: /c/Users/TravLaptop/.ssh/id_ecdsa                          
debug1: Trying private key: /c/Users/TravLaptop/.ssh/id_ed25519                        
debug1: Trying private key: /c/Users/TravLaptop/.ssh/id_xmss                           
debug1: No more authentication methods to try.                                         
git@bitbucket.org: Permission denied (publickey).                                      
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 27, 2018

Hello again Travis,

Thank you for being patient and working through this.

Here is the structure of the URL:

You'll see these names as part of the URL:

  • In place of <repo_name>, you'll see the repository name.
  • In place of <your_username> in the HTTPS URL format, you'll see the username for your individual account.
  • In place of <account_name> for all URL formats, you'll the user or team name for the account that owns the repository.<your_username> and <account_name> may be the same if you're looking at the URL for a repository you own.

Git repository URLs

HTTPS format:

https://<your_username>@bitbucket.org/<account_name>/<repo_name>.git

SSH format:

git@bitbucket.org:<account_name>/<repo_name>.git

or

ssh://git@bitbucket.org/<account_name>/<repo_name>.git

Mercurial repository URLs

HTTPS format

https://<your_username>@bitbucket.org/<account_name>/<repo_name>

SSH format

ssh://hg@bitbucket.org/<account_name>/<repo_name>/

Source document: https://confluence.atlassian.com/bitbucket/update-your-username-226165171.html

The error you are receiving is mirroring the error within: Permission denied (publickey)

The SSH key is not recognizable by Bitbucket based on the keys presented. Give the following a run through:

Diagnosis

You are receiving this message because Bitbucket Cloud could not authenticate you with any of the keys that were offered to it by your SSH agent. To verify this is the case, do the following

ssh -T hg@bitbucket.org

This will attempt to create a connection to Bitbucket Cloud for Mercurial. You should receive a response similar to the following if your key is correctly loaded

$ ssh -T hg@bitbucket.org
conq: logged in as username.

If you do not see a message similar to the above, read on. Permission denied (publickey)

Most likely, your SSH key listed below is not correct:

debug1: Will attempt key: /c/Users/TravLaptop/.ssh/id_rsa                              

Let me know the results of the above to see if the issue is your SSH keys.

Regards,
Stephen Sifers

RetroVertigo December 27, 2018

Hey Stephen

  So I continued working on this, and now I believe I have the SSH keys in the correct area on BitBucket, which is to say, it is within BitBucket settings, and not within the Repo Settings.  So, with that setup, I re ran the commands, and I still have the permission denied from bitbucket.  Which is saying that it does not have the public key, but I have uploaded it to there, so I am out of options here.  I am not sure what to do next.

 

Thanks

RetroVertigo December 27, 2018

Just an update, I uninstalled SourceTree and re installed it and still I have the issue.  I am getting really frustrated with this, as I just want to push a commit and I should have it all setup correctly.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events