gnutls_handshake() failed: Handshake failed GIT

Ran into the same issue on a server with Ubuntu 14.04, and found that on Aug 24, 2020 bitbucket.org changed to no longer allow old ciphers, see https://bitbucket.org/blog/update-to-supported-cipher-suites-in-bitbucket-cloud

This affects https:// connections to bitbucket, but does not affect ssh connections, so the quickest solution for me was to add an ssh key to bitbucket, and then change the remote from https to ssh.

The steps to change the remote I found from here, and they are essentially:

# Find the current remote
git remote -v

origin  https://[email protected]/reponame.git (fetch)
origin  https://[email protected]/reponame.git (push)

# Change the remote to ssh
git remote set-url origin [email protected]:reponame.git

# Check the remote again to make sure it changed
git remote -v

There is more discussion about the issue on the Atlassian forums at https://community.atlassian.com/t5/Bitbucket-questions/fatal-unable-to-access-https-bitbucket-org-gnutls-handshake/qaq-p/1468075


The quickest solution is to use SSH instead of HTTPS. I tried other ways to fix the issue but it was not working.

The following are steps to replace HTTPS from SSH:

  1. Generate ssh key using ssh-keygen on the server.

  2. Copy the public key from the generated id_rsa.pub file from step 1 and add it at following links depending on the repository host -

    Bitbucket - https://bitbucket.org/account/settings/ssh-keys/

    Github - https://github.com/settings/ssh/new

    Gitlab - https://gitlab.com/profile/keys

  3. Now run the following command to test authentication from the server command line terminal

    Bitbucket

    ssh -T [email protected]
    Github
    ssh -T [email protected]
    Gitlab
    ssh -T [email protected]

  4. Go to the repo directory and open .git/config file using emac or vi or nano

  5. Replace remote "origin" URL (which starts with https) with the following -

    For Bitbucket - [email protected]:<username>/<repo>.git

    For Github - [email protected]:<username>/<repo>.git

    For Gitlab - [email protected]:<username>/<repo>.git