Unable to push via ssh
Asked by ????:

Hello everyone!

I have a permanent error on **git push** command via ssh:

```
Unauthorized
fatal: Could not read from remote repository.

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

And it makes me crazy (

So, given:

1. Generated ssh keys (public and private) on the local repository side.
2. Public key added to "Access keys" settings of my private bitbucket repository.
3. *ssh -T git@bitbucket.org* command gives **successful** message:  
   *authenticated via ssh key.*   
   *You can use git to connect to Bitbucket. Shell access is disabled*
4. BUT *git push* command gives "unauthorized" error!

I've been through tons of discussions and tried following:

1. Transfer key from repo settings to the account settings. But then *git push* gives another error:

   ```
   fatal: unable to create thread: Resource temporarily unavailable
   error: failed to push some refs to 'git@bitbucket.org:<user>/<proj>.git'
   ```

2. Create .ssh/config file and put there:

   ```
   Host bitbucket.org
     IdentityFile ~/.ssh/id_rsa
     IPQoS=throughput
   ```

   No effect.
3. Regenerate keys. No effect.

I've spent 2 days with it and I don't have any more ideas where is the problem.

Help me please!


Answers:
author: Mohamed Adel
body: Hi [@????](/t5/user/viewprofilepage/user-id/4906242)

I wonder if you tried the following solution in this [Can't git push to Bitbucket: Unauthorized - fatal: Could not read from remote repository](https://stackoverflow.com/questions/56828685/cant-git-push-to-bitbucket-unauthorized-fatal-could-not-read-from-remote-re)

Regards,

Mohamed Adel

comments: author: ????
body: Yes, I;ve tried it. I've pointed it in my question:
> I've been through tons of discussions and tried following:  
>
> 1. Transfer key from repo settings to the account settings. But then *git push* gives another error:
>
> ```
> fatal: unable to create thread: Resource temporarily unavailable
> error: failed to push some refs to 'git@bitbucket.org:<user>/<proj>.git
> ```

As a result I get another error "resource unavailable". (


author: Mohamed Adel
body: then did you try that one :)

<https://stackoverflow.com/questions/9905257/git-push-fatal-unable-to-create-thread-resource-temporarily-unavailable>


author: ????
body: Hmm... Missed this thread for some reason. )  
Thank you a lot!

After following that hints I'd got the next problem: "failed to push some refs to remote". And I'd solve it with this thread: <https://stackoverflow.com/questions/24114676/git-error-failed-to-push-some-refs-to-remote> (recreate repository with named "master" instead "main" by default)


author: ????
body: *ssh -v git@bitbucket.org* gives the following:

```
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /home/ilexaru/.ssh/config
debug1: /home/ilexaru/.ssh/config line 1: Applying options for bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to bitbucket.org [104.192.141.1] port 22.
debug1: Connection established.
debug1: identity file /home/ilexaru/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/ilexaru/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version conker_bb796ffc5d fdf5fd4970f6
debug1: no match: conker_bb796ffc5d fdf5fd4970f6
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: rsa-sha2-512
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/ilexaru/.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: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-rsa,rsa-sha2-256,ecdsa-sha2-nistp256>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ilexaru/.ssh/id_rsa
debug1: Server accepts key: pkalg rsa-sha2-512 blen 279
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([104.192.141.1]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
PTY allocation request failed on channel 0
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Connection to bitbucket.org closed.
Transferred: sent 3052, received 2168 bytes, in 0.3 seconds
Bytes per second: sent 11877.9, received 8437.5
debug1: Exit status 0
```


Tags: bitbucket-cloud

cloud

ssh