Gitlab CI - ssh to docker container

i’ve been trying to use ssh to connect into my docker container which i use as a web server.

but when running ssh connect in gitlab CI, i am getting a time out

OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *debug1: Connecting to x.x.x.x [x.x.x.x] port 5000.
debug1: connect to address x.x.x.x port 5000: Connection timed out
ssh: connect to host x.x.x.x port 5000: Connection timed out

my .gitlab.yml :

image: ubuntu:latest
before_script:
   - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
   - eval $(ssh-agent -s)
   - ssh-add <(echo "$SSH_PRIVATE_KEY")
   - mkdir -p ~/.ssh
   - chmod 700 ~/.ssh

deploy_stage:
   stage: deploy
   environment: Staging
   only:
      - master
   script:
      - ssh -v -p 5000 toto@x.x.x.x "ls"

i am able to connect with any other shell, but not when using gitlab CI.
any idea on how to fix it ?

Hey @keatchut are you able to solve that? I’m facing same issue…

Hi
Do you use the shared runner from Gitlab ?
Is your server accesable from outside ?

If you use a shared runner, the server needs to be accesable from anywhere.

If you use your own runner, the server hosting the runner needs to be have acces to the server.

Kevin atchuthan.

Hello Sir, I am having the same problem after changing the ssh port before that it was working fine and i am using a shared runner.