Skip to content

Instantly share code, notes, and snippets.

@vslala
Created May 27, 2020 16:53
Show Gist options
  • Select an option

  • Save vslala/528419f2c32b46d09c4bd313acd8d7d3 to your computer and use it in GitHub Desktop.

Select an option

Save vslala/528419f2c32b46d09c4bd313acd8d7d3 to your computer and use it in GitHub Desktop.
Step by step commands to ssh into vps and fire commands
stages:
- sshserver
variables:
REGISTRY_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
test:
image: alpine:latest
stage: sshserver
script:
- echo "Alpine image created!"
- apk update && apk add openssh-server openssh-client
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SERVER_KEY" | tr -d '\r' | ssh-add -
- echo "$SERVER_KEY" > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh -i ~/.ssh/id_rsa -o "StrictHostKeyChecking no" ${SERVER_USERNAME}@${SERVER_IP} 'echo $HOME'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment