Last active
June 4, 2020 14:36
-
-
Save kas-cor/316a486eae32298f20524351d5e83e5d to your computer and use it in GitHub Desktop.
My gitlab CI for SSH Exes deploy
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
| image: jimmyadaro/gitlab-ci-cd:latest | |
| before_script: | |
| - mkdir -p ~/.ssh | |
| - echo "$PRIVATE_KEY" > ~/.ssh/id_rsa | |
| - chmod 700 ~/.ssh | |
| - chmod 600 ~/.ssh/id_rsa | |
| - eval $(ssh-agent -s) | |
| - ssh-add ~/.ssh/id_rsa | |
| Deploy: | |
| stage: deploy | |
| only: | |
| - master | |
| script: | |
| - cat ./deploy.sh | ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa -p $SERVER_PORT $SERVER_USER@$SERVER_HOST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
In GitLab.com
Goes to
settings>CI / CD>VariablesCreate variables:
PRIVATE_KEY- Private key without passphrase in "OpenSSH" formatSERVER_HOST- Host/ip remote serverSERVER_USER- User name of remote serverSERVER_PORT- Port of remote serverIn remote server
Add public key without passphrase in
~/.ssh/authorized_keysin "OpenSSH" format