Search code examples
gitsshbitbucketssh-keys

GIT push Unauthorized when SSH keys already added


I don't have any branch permission set, I also already added public key into BitBucket SSH settings.

┌──[forge@app]──[~/app]                                                                  
└── git status                                                                               
On branch master                                                                             
Your branch is ahead of 'origin/master' by 2 commits.                                        
  (use "git push" to publish your local commits)                                             
nothing to commit, working directory clean                                                   
┌──[forge@app]──[~/app]                                                                  
└── git push origin master                                                                   
Unauthorized                                                                                 
fatal: Could not read from remote repository.                                                

Please make sure you have the correct access rights and the repository exists.                                                                   
┌──[forge@app]──[~/app]                                                                  
└──  

I kept getting

Unauthorized
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.


Solution

  • Check first your current remote URL:

    cd ~/app
    git remote -v
    

    It should be like git@bitbucket.org:<me>/<myproject>

    Then check the output of:

    ssh -Tv git@bitbucket.org
    

    You will see if you are correctly authenticated.