Search code examples
sshbitbucketgitlabpublic-keygitlab-omnibus

Where to store the ssh public key for connecting GitLab to Bitbucket?


I'd like to connect (an Omnibus install of) GitLab to Bitbucket. According to the documentation, I need to create and store a public key for it:

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.

The fact is I don't have a /home/git. How could I know, then, where I must create the public key, so that GitLab notices it and registers it automatically?


Solution

  • The home directory for the git User in an Omnibus install is by default /var/opt/gitlab. You can either check your gitlab.rb config file for the key user['home'] and see if you have modified it or do a cat /etc/passwdand find the home diretory for the user git there.

    Default value user['home'](remember the # means it is commented out):

    # user['home'] = "/var/opt/gitlab"

    Output of cat /etc/passwd | grep git:

    git:x:1000:1000:git,,,:/var/opt/gitlab:/bin/sh

    Once you have found out where the home directory for the user git is, you can put bitbucket_rsa.pub in the folder .ssh. If it doesn't exist you can create that folder.