2

I have a server in Iran and i want use gitlab ci to open an ssh tunnel to my server.

But thanks to Google cloud services, gitlab can not see Iran IPs.

Is there any way to use a middle server out of iran to open a proxy tunnel from gitlab to my proxy server and from that to my Iran server, then use docker to pull an image from gitlab registery?

Consider Iran servers can't connect to gitlab an gitlab can not connect to Iran servers too.

Thank you

2 Answers 2

5
+100

I have succeeded with such code

before_script:
  - apt-get update -y
  - apt-get install openssh-client curl -y


integration:
  stage: integration
  script:
    - mkdir ~/.ssh/
    - eval $(ssh-agent -s)
    - echo "$SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
    - chmod 600 ~/.ssh/id_rsa
    - ssh -fN -L 1029:localhost:1729 user@$HOST -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no 2>&1
    - ssh -fN -L 9013:localhost:9713 user@$HOST -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no 2>&1
Sign up to request clarification or add additional context in comments.

Comments

2

Also this is worked for me

deploy:
  environment:
    name: production
    url: http://example.com
  image: ubuntu:latest
  stage: deploy
  only:
    - master
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    ## Install rsync to create mirror between runner and host.
    - apt-get install -y rsync
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - eval $(ssh-agent -s)
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
  script:
    - ssh-add <(echo "$SSH_PRIVATE_KEY" | base64 --decode)
    - ssh -o StrictHostKeyChecking=no $SSH_USER@"$SSH_HOST" 'ls -la && ssh user@host "cd ~/api && docker-compose pull && docker-compose up -d"'

I also described everything that i did in Farsi here: https://virgol.io/@aminkt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.