Cannot connect GitLab to Bitbucket


I’ve got a fresh Omnibus install of GitLab in which I’d like to import a Bitbucket project. GitLab documentation tells me that I first need to enable OmniAuth, which I have done, it’s working fine, I can login with my Bitbucket account. However the “Project import” part is giving me headaches.

GitLab will automatically register your public key with Bitbucket as a deploy key for the repositories to be imported. Your public key needs to be at ~/.ssh/, which will expand to /home/git/.ssh/ in most configurations.

I’ve got no /home/git directory on my server, so where should I generate this public key? I tried to find the git account’s home dir by myself with grep git /etc/passwd, which gives me:


So I guess instead of /home/git I should use /var/opt/gitlab (even though it’s owned by root:root…)

Then I do:

sudo -u git -H ssh-keygen # I ask the file to be /var/opt/gitlab/.ssh/bitbucket_rsa
sudo vi /var/opt/gitlab/.ssh/config

In which I write:

  IdentityFile ~/.ssh/bitbucket_rsa
  User git

And then:

sudo -u git -H ssh -v

Which fails with a “Permission denied” error:

OpenSSH_6.7p1 Debian-5, OpenSSL 1.0.1k 8 Jan 2015
debug1: Reading configuration data /var/opt/gitlab/.ssh/config
debug1: /var/opt/gitlab/.ssh/config line 1: Applying options for
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to [] port 22.
debug1: Connection established.
debug1: identity file /var/opt/gitlab/.ssh/bitbucket_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /var/opt/gitlab/.ssh/bitbucket_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr none
debug1: kex: client->server aes128-ctr none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
debug1: Host '' is known and matches the RSA host key.
debug1: Found key in /var/opt/gitlab/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /var/opt/gitlab/.ssh/bitbucket_rsa
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

Can anyone tell me what I am doing wrong, please?

Documentation for Bitbucket sure needs update. It’s on my roadmap. Until then check this blog post which sums it well

Sorry for the trouble :confused: