Last active
June 17, 2020 10:12
-
-
Save diginfo/68261e9709eb05046d473f9fc646389f to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
## bash <(curl -Ls https://gist.github.com/diginfo/68261e9709eb05046d473f9fc646389f/raw/) | |
### | |
if [ "$#" -lt 2 ]; then | |
echo "keyadd repo path/to/rsa/file" | |
exit 1; | |
fi | |
REPO=$1; | |
PUBKEY=$2; | |
CONFIG="/etc/ssh/ssh_config" | |
HEAD="## github - $REPO ##"; | |
#if ! grep -Fxq "$HEAD" $CONFIG; then | |
echo "adding config..." | |
cat <<EOF >>$CONFIG | |
$HEAD | |
Host $REPO.github.com | |
Hostname github.com | |
IdentityFile $PUBKEY | |
User diginfo | |
EOF | |
#fi | |
chmod 400 $PUBKEY; | |
## Add github.com to known hosts | |
ssh-keyscan github.com >> ~/.ssh/known_hosts | |
cat $CONFIG; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment