bonhoffer
bonhoffer

Reputation: 1473

Can't SSH into Gitlab

I have a gitlab ce image running via docker-compose

gitlab:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.theboohers.org'
        # Add any other gitlab.rb configuration here, each on its own line
    ports:
      - '8000:80'
      - '8001:443'
      - '22:22'
    volumes:
      - '$GITLAB_HOME/config:/etc/gitlab'
      - '$GITLAB_HOME/logs:/var/log/gitlab'
      - '$GITLAB_HOME/data:/var/opt/gitlab'
    networks:
      - app-network

I can login via https, (using nginx proxy), but I can't authenticate via ssh.

I verified that port 22 is listening:

nc -vz gitlab.theboohers.org 22
Connection to gitlab.theboohers.org (194.195.222.5) 22 port [tcp/ssh] succeeded!

In the verbose output, I see that the key is being offered: debug1: Offering public key: /home/deploy/.ssh/id_rsa RSA SHA256

But I'm met with the error: [email protected]: Permission denied (publickey).

Full verbose ssh connection at: https://gist.github.com/tbbooher/336e1bb277456efde6003111a56f3118

Upvotes: 1

Views: 1804

Answers (1)

Quentin Petel
Quentin Petel

Reputation: 625

To be able to connect with ssh, I had to add the following lines in the GITLAB_OMNIBUS_CONFIG environment variable :

    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://${GITLAB_HOST}'
        # ...
        gitlab_rails['gitlab_shell_ssh_port'] = ${SSH_PORT}

and to open the port (as you have) :

    ports:
      - ${SSH_PORT}:22

After that, i was able to clone repositories with urls like :

git clone ssh://git@${GITLAB_HOST}:${SSH_PORT}/${REPOSITORY}.git

Note that the port 22 was already used and I had to set another one.

Upvotes: 2

Related Questions