docker-gitlab icon indicating copy to clipboard operation
docker-gitlab copied to clipboard

Failed to git clone through ssh

Open myugan opened this issue 3 years ago • 2 comments

In this case, I have 2 containers which are GitLab CE and ubuntu machine, I want to clone a repo in Ubuntu machine using SSH protocol but it seems getting a failed like the below:

Note: I've configured GitLab host URL to the container name instead of the domain.

$ git clone git@gitlab-ce-JZGNEecD:root/django-nv.git
Cloning into 'django-nv'...
The authenticity of host 'gitlab-ce-jzgneecd (x.x.x.x)' can't be established.
ECDSA key fingerprint is SHA256:j2YNp45KLBNRwlSe5CYjNVWSAVG6X5eewpwbhpQIE5I.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitlab-ce-jzgneecd,x.x.x.x' (ECDSA) to the list of known hosts.
fatal: 'root/django-nv.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

myugan avatar May 04 '21 22:05 myugan

Hi,

apparently the SSH connection is established. But I guess that you can't address one of the two Gitlab installations this way.

I rather think that the host system (in your case Ubuntu) responds to the SSH connection and none of the Gitlab containers. (In this case, git is trying to clone the repo, which is not present on the host).

Can you tell me how the SSH ports for.

  • the host system and
  • the gitlab container (gitlab-ce-JZGNEecD)

are? And how does your reverse proxy configuration look like?

sachilles avatar Jun 10 '21 14:06 sachilles

I have the same issue.

I am not using a reverse proxy to forward the port, I just map it to a different port in docker.

This is my docker-compose file:

version: '3.7'
services:
  gitlab:
    image: sameersbn/gitlab:latest
    container_name: gitlab
    restart: always
    depends_on:
     - postgres
     - redis
    environment:
     - DEBUG=false

     - DB_ADAPTER=postgresql
     - DB_HOST=postgres
     - DB_PORT=5432
     - DB_USER=XXX
     - DB_PASS=XXX
     - DB_NAME=gitlabhq_production

     - REDIS_HOST=redis
     - REDIS_PORT=6379 

     - GITLAB_HTTPS=false
     - SSL_SELF_SIGNED=falsec

     - GITLAB_HOST=gitlab.example.com
     - GITLAB_PORT=80
     - GITLAB_SSH_PORT=9954
     - GITLAB_SECRETS_DB_KEY_BASE=XXX
     - GITLAB_SECRETS_SECRET_KEY_BASE=XXX
     - GITLAB_SECRETS_OTP_KEY_BASE=XXX
     - GITLAB_REGISTRY_ENABLED=true
     - GITLAB_REGISTRY_HOST=registry
     - GITLAB_REGISTRY_PORT=5000
     - GITLAB_REGISTRY_API_URL=http://registry:5000
     - GITLAB_REGISTRY_CERT_PATH=/certs/registry.crt
     - GITLAB_REGISTRY_KEY_PATH=/certs/registry.key
    shm_size: 4gb
    ports:
     - '9954:22'
    volumes:
     - XXX:/home/git/data
     - XXX:/certs
    healthcheck:
      test: ["CMD", "/usr/local/sbin/healthcheck"]
      interval: 5m
      timeout: 10s
      retries: 3
      start_period: 5m
    networks:
     - traefik
     - gitlab
    labels:
      traefik.enable: true
      traefik.docker.network: traefik
      traefik.http.routers.gitlab.rule: Host(`gitlab.example.com`)
      traefik.http.routers.gitlab.entrypoints: websecure
      traefik.http.routers.gitlab.service: gitlab
      traefik.http.services.gitlab.loadbalancer.server.port: 80

networks:
  gitlab:
    driver: bridge
    name: gitlab
    ipam:
      config:
        - subnet: 192.169.1.0/16
  traefik:
    external: true

michaelvanstraten avatar May 23 '22 10:05 michaelvanstraten