Hello! I’m using shared hosting. They provide SSH access to the www directory for specific IPs.
So I’m trying to configure .gitlab-ci.yml to build and deploy files from GitLab repository.
Here is my pipeline:
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 $USERNAME@$HOST:$PATH_TO_WWW
Result
...
$ eval $(ssh-agent -s)
Agent pid 13
$ echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
Identity added: (stdin) (username@domain.com)
$ mkdir -p ~/.ssh
$ chmod 700 ~/.ssh
$ scp -o StrictHostKeyChecking=no public.zip $USERNAME@$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) is not working.
Hosting supports advise to add GitlabCI IP to the list of white IPs but I found no working IPs with Google.
I tried to make an SCP request from my home laptop with static IP and it’s working