B
B
Boris Manzhela2020-12-09 04:38:36
SSH
Boris Manzhela, 2020-12-09 04:38:36

Port 22: Network unreachable or How to make GitLab CI and shared hosting friends?

Hey!
There is a shared hosting that has access to the SSH project folder, but it is issued only for manually specified IPs
. The problem is that gitlab ci cannot connect via SSH

deploy:
  stage: deploy
  image: alpine
  before_script:
    - apk add openssh-client
    - eval $(ssh-agent -s) 
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
  script:
    - scp -o StrictHostKeyChecking=no public.zip [email protected]$HOST:$PATH_TO_WWW


Error that displays on fail

...
$ eval $(ssh-agent -s)
Agent pid 13
$ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
Identity added: (stdin) ([email protected])
$ mkdir -p ~/.ssh
$ chmod 700 ~/.ssh
$ scp -o StrictHostKeyChecking=no public.zip [email protected]$HOST:$PATH_TO_WWW
ssh: connect to host ukrcolor.ftp.tools port 22: Network unreachable
lost connection
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1


Changing IP XXX.XXX.XXX.XX instead of ukrcolor.ftp.tools ($HOST) did not help.
Support advises adding an IP from which gitlab ci will come in, but there is no open data on the lists. Several IP options that I found on the Internet do not work. But if you execute SCP locally, then the file is regularly sent to the hosting

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2020-12-09
@vitaly_il1

Support advises adding an IP from which gitlab ci will come, but there is no open data on the lists.

As far as I understand, GitLab CI does not have an address list - https://docs.gitlab.com/ee/user/gitlab_com/#ip-range .
So just switch to another CI, or use your own runner.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question