Search code examples
gitsshgitlabgitlab-ci-runner

How to SSH into a seperate Gitlab instance's runner


I have two Gitlab runner instances on my server, both of which have a gitlab runner. They are both named "gitlab-runner". Whenever I SSH into a gitlab runner using the command sudo su - gitlab-runner I always get into the first instance's runner. How do I get access to the other one?


Solution

  • Based on my understanding, you are running two gitlab runners in the same server. I would modify the /etc/gitlab-runner/config.toml file and assign the runners different names.

    vi /etc/gitlab-runner/config.toml
    

    For example,

    [[runners]]
      name = "gitlab-runner-1"
      url = "https://your.url.com/"
      token = "your-token"
      executor = "docker"
    
      [runners.docker]
        tls_verify = false
        image = "openjdk:11-jdk-slim-sid"
        privileged = false
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache"]
        shm_size = 0
        limit = 1
    
    [[runners]]
      name = "gitlab-runner-2"
      url = "https://your.url.com/"
      token = "your-token"
      executor = "docker"
    
      [runners.docker]
        tls_verify = false
        image = "openjdk:11-jdk-slim-sid"
        privileged = false
        disable_entrypoint_overwrite = false
        oom_kill_disable = false
        disable_cache = false
        volumes = ["/cache"]
        shm_size = 0
        limit = 1
    

    After modifying the config, you will have to restart the gitlab-runner. The following command may help.

    service gitlab-runner restart