Created
November 23, 2021 10:45
-
-
Save liflovs/f2a950dadcca25a0dbdfe10f53f5c838 to your computer and use it in GitHub Desktop.
Git SSH key from environmental variable
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
#!/usr/bin/env bash | |
# Init .ssh dir and expand $SSH_KEY | |
mkdir -p ~/.ssh | |
echo -e "${SSH_KEY//_/\\n}" > ~/.ssh/id_rsa | |
chmod og-rwx ~/.ssh/id_rsa | |
# Uncomment to debug | |
# ls -la ~/.ssh | |
# cat ~/.ssh/id_rsa | |
# Add host keys, comment out if not needed | |
ssh-keyscan -H github.com >> ~/.ssh/known_hosts | |
ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment