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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get write access to a git repository using public key

Added my home public key to git repository settings but still see question about password during push command on my home machine.

I am sure that public key is correct. I already use that to auth to my remote sandboxes.

I spent time for investigation but found nothing useful. Please advise.

1 answer

1 accepted

1 vote
Answer accepted
Mikael Sandberg Community Leader Feb 17, 2020

Hi @nskforward,

Welcome to the Atlassian Community.

Did you update the remote URL for your repository to use SSH?

$ git remote set-url origin ssh://git@bitbucket.org:dreamqsoftware/www.git

$ git push

Unauthorized
fatal: Could not read from remote repository.

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

Mikael Sandberg Community Leader Feb 18, 2020

Run ssh -vT bitbucket.org, it should tell you where SSH is getting your private key from. 

[ivan@localhost ~]$ ssh -vT bitbucket.org
OpenSSH_8.1p1, OpenSSL 1.1.1d FIPS 10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: Connecting to bitbucket.org [18.234.32.155] port 22.
debug1: Connection established.
debug1: identity file /home/ivan/.ssh/id_rsa type 0
debug1: identity file /home/ivan/.ssh/id_rsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_dsa type -1
debug1: identity file /home/ivan/.ssh/id_dsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_ecdsa type -1
debug1: identity file /home/ivan/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_ed25519 type -1
debug1: identity file /home/ivan/.ssh/id_ed25519-cert type -1
debug1: identity file /home/ivan/.ssh/id_xmss type -1
debug1: identity file /home/ivan/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.1
debug1: Remote protocol version 2.0, remote software version conker_04c2dec4ed app-155
debug1: no match: conker_04c2dec4ed app-155
debug1: Authenticating to bitbucket.org:22 as 'ivan'
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: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: kex: curve25519-sha256@libssh.org need=64 dh_need=64
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /home/ivan/.ssh/known_hosts:7
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/ivan/.ssh/id_rsa RSA SHA256:8oDSNFa5h+zmoYqhdWryOrwyxPXy0kI7ehpL1yI5PFA agent
debug1: Will attempt key: /home/ivan/.ssh/id_dsa
debug1: Will attempt key: /home/ivan/.ssh/id_ecdsa
debug1: Will attempt key: /home/ivan/.ssh/id_ed25519
debug1: Will attempt key: /home/ivan/.ssh/id_xmss
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/ivan/.ssh/id_rsa RSA SHA256:8oDSNFa5h+zmoYqhdWryOrwyxPXy0kI7ehpL1yI5PFA agent
debug1: Server accepts key: /home/ivan/.ssh/id_rsa RSA SHA256:8oDSNFa5h+zmoYqhdWryOrwyxPXy0kI7ehpL1yI5PFA agent
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([18.234.32.155]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env XMODIFIERS = @Im=ibus
debug1: Sending env LANG = en_GB.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
authenticated via a deploy key.

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

This deploy key has read access to the following repositories:
dreamqsoftware/www

debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3112, received 2024 bytes, in 3.8 seconds
Bytes per second: sent 809.7, received 526.6
debug1: Exit status 0

Mikael Sandberg Community Leader Feb 18, 2020

Okay, it looks like your key is set up to only have read access.

Did you add your key under access keys on the repository or as part of your profile? If you do it as an access key you will only have read permissions which only allows to clone and pull from the repository.

Like nskforward likes this

Fixed. Many thanks, Mikael. It was the root cause.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

442 views 4 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you