Cannot connect GitLab to Bitbucket

Hi,

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/bitbucket_rsa.pub, which will expand to /home/git/.ssh/bitbucket_rsa.pub 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:

gitlab-www:x:999:999::/var/opt/gitlab/nginx:/bin/false
git:x:998:998::/var/opt/gitlab:/bin/sh
gitlab-redis:x:997:997::/var/opt/gitlab/redis:/bin/nologin
gitlab-psql:x:996:996::/var/opt/gitlab/postgresql:/bin/sh

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:

Host bitbucket.org
  IdentityFile ~/.ssh/bitbucket_rsa
  User git

And then:

sudo -u git -H ssh bitbucket.org -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 bitbucket.org
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to bitbucket.org [131.103.20.168] 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 umac-64@openssh.com none
debug1: kex: client->server aes128-ctr umac-64@openssh.com 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 'bitbucket.org' 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_REQUEST sent
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 http://stratus3d.com/blog/2015/09/06/migrating-from-bitbucket-to-local-gitlab-server/

Sorry for the trouble :confused: