Created
May 27, 2020 16:53
-
-
Save vslala/528419f2c32b46d09c4bd313acd8d7d3 to your computer and use it in GitHub Desktop.
Step by step commands to ssh into vps and fire commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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