Pipeline deployment ssh port different

pipelin deployment with different ssh port

How do I deploy with different ssh port?:

  • What are you seeing, and how does that differ from what you expect to see?
    Could not resolve hostname development.hostname.com:6262: Name does not resolve

  • Consider including screenshots, error messages, and/or other helpful visuals

  • What version are you on? Are you using self-managed or GitLab.com?
    version 14.7.1-ee
    self-hosted gitlab en the runner is docker type

pipeline

deploy:
image: tmaier/docker-compose:latest
services:
- docker:dind
stage: Deploy-development
variables:
CONTAINER_NAME: back-end-dev
CONTAINER_PORT: 8080
SSH_PORT: 6262
before_script:
- apk add openssh-client
- eval $(ssh-agent -s)
- echo “$DEV_SSH_KEY” | tr -d ‘\r’ | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- echo “----Deploying application-------”
- ssh -o StrictHostKeyChecking=no $DEV_SSH_USERNAME@$DEV_SSH_HOSTNAME:$SSH_PORT “docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY”
- ssh -o StrictHostKeyChecking=no $DEV_SSH_USERNAME@$DEV_SSH_HOSTNAME:$SSH_PORT “docker-compose down --remove-orphans”
- echo “----DOCKER-COMPOSE PULL---------”
- ssh -o StrictHostKeyChecking=no $DEV_SSH_USERNAME@$DEV_SSH_HOSTNAME:$SSH_PORT “docker pull $CONTAINER_BACKEND_IMAGE”
- echo “DOCKER IMAGE LIST”
- docker images
- echo “STARTING CONTAINERS USING DOCKER-COMPOSE”
- ssh -o StrictHostKeyChecking=no $DEV_SSH_USERNAME@$DEV_SSH_HOSTNAME:$SSH_PORT “docker-compose up -d”
environment: development
only:
- master
*

  • What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?

-L 6262

I have also changed port number under gitlab settings /etc/gitlab/gitlab.rb I have change to different port

gitlab_rails[‘gitlab_shell_ssh_port’] = 7171

1 Like

when you run the ssh command down here

- ssh -o StrictHostKeyChecking=no $DEV_SSH_USERNAME@$DEV_SSH_HOSTNAME:$SSH_PORT

You need to modify this as the ssh command does not typically support the : port identifier. Change it to

- ssh -o StrictHostKeyChecking=no $DEV_SSH_USERNAME@$DEV_SSH_HOSTNAME -p $SSH_PORT
1 Like

Hi jemmy, thanks that have solved my problem