Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot push using git on linux

Gleb Kartashov July 19, 2022

Steps I've taken:

Follow this guide exactly https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/

This is my test connection message:

ssh -T git@bitbucket.org
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

 This is message I get when I try to push my files into my repo

root@jirau-virtual-machine:/var/atlassian/application-data/jira/scripts# git push bitbucket2
root@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 This repo does exist in my Bitbucket Cloud and was created by me

My remote settings:

root@jirau-virtual-machine:/var/atlassian/application-data/jira/scripts# git remote -v
bitbucket2 ssh://bitbucket.org/inforcekz_jira/scripts/src/master/ (fetch)
bitbucket2 ssh://bitbucket.org/inforcekz_jira/scripts/src/master/ (push)

SSH settings under Personal settings in Bitbucket:

image.png

SSH port is open on my VM as I can only connect to it via SSH

2 answers

0 votes
Piotr Karzełek July 22, 2022

I've got the same issue, but I found better solution, I just changed remote from git@bitbucket.org into user@bitbucket.org

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 20, 2022

Hey Gleb,

Welcome to the Bitbucket Cloud Community!

A common issue I see is that the SSH will authenticate, but it will not use the correct key and therefore will fail to grant access.
Please try to update your remote URL as follows to specify the username to authenticate with in GIT, provided your ~/.ssh/config file has been mapped correctly this should authenticate without issues:

git remote set-url origin username@bitbucket.org:workspaceID/reposlug.git
If this does not work, try to edit your config file directly to, again, specify the username that you would be using to authenticate with - replacing "username" in the text below:
#username account
Host bitbucket.org-username
HostName bitbucket.org
User git
IdentityFile ~/.ssh/privatekeyname
IdentitiesOnly yes
Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events