Skip to content

Instantly share code, notes, and snippets.

@vtenq
Created August 28, 2019 09:22
Show Gist options
  • Save vtenq/e6e6c9e6d664721b5b028b5ae319d5e8 to your computer and use it in GitHub Desktop.
Save vtenq/e6e6c9e6d664721b5b028b5ae319d5e8 to your computer and use it in GitHub Desktop.
# Install ssh client if not installed yet
- 'which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)'
- eval $(ssh-agent -s)
# Add ssh private to the agent where $SSH_PRIVATE_KEY is env variable
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
# Add remote server to known hosts (change IP Address, and also the remote server
# should already have public key installed so that it will be possible to connet)
- ssh-keyscan -H 127.0.0.1 >> ~/.ssh/known_hosts
# Set appropriate access for known_hosts file
- chmod 644 ~/.ssh/known_hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment