Last active
January 17, 2018 23:42
Revisions
-
kaji-bikash revised this gist
Jan 17, 2018 . 1 changed file with 12 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,14 +9,20 @@ fi #Assumptions #Default user deploy whose SSH authorized_keys is to modify #SSH authorized_keys is in the format ssh-rsa key home=${home:-deploy} username=$1 name=`curl --silent https://api.github.com/users/$username | grep "name" | awk -F: '{ print $2}' | cut -d "," -f1` prompt() { echo "" echo "You are adding $username - $name" read -n1 -r -p "To avoid unintended additions, press any key to continue..." key #if ! [ "$key" = "y" ]; then # exit 1; #fi } prompt; @@ -30,7 +36,7 @@ ssh_auth_file=`eval echo ~${home}/.ssh/authorized_keys` ##Append found keys to authorized_keys file while read line do echo "$line ${username}" >> ${ssh_auth_file} done <"/tmp/${username}.pub" #Simulate idempotence/de-duplication @@ -40,7 +46,8 @@ mv ${ssh_auth_file}.uniq ${ssh_auth_file} if [ $? -eq "0" ]; then echo "" echo "SUCCESS : $name - $username added"; exit 0; fi echo "" echo "FAILED: $name - $username not added"; exit 1; -
kaji-bikash revised this gist
Jan 17, 2018 . 1 changed file with 17 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,6 +12,14 @@ fi #SSH authorized_keys is in the format ssh-rsa key home=${home:-deploy} username=$1 name=`curl --silent https://api.github.com/users/kajisaap | grep "name" | awk -F: '{ print $2}' | cut -d "," -f1` prompt() { echo "You are adding $username - $name" read -p "To avoid unintended pubkey additions, press ENTER/RETURN to continue: " } prompt; #get public key from a github KEY="https://github.com/$username.keys" @@ -27,4 +35,12 @@ done <"/tmp/${username}.pub" #Simulate idempotence/de-duplication cat $ssh_auth_file | sort -u -k1,2 > ${ssh_auth_file}.uniq mv ${ssh_auth_file}.uniq ${ssh_auth_file} if [ $? -eq "0" ]; then echo "SUCCESS : $name - $username added"; exit 0; fi echo "FAILED: $name - $username not added"; exit 1; -
kaji-bikash revised this gist
Jan 17, 2018 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,12 @@ #!/bin/bash usage() { echo "Usage: $0 github-username" 1>&2; exit 1; } if [ $# -lt "1" ]; then usage; fi #Assumptions #Default user deploy whose SSH authorized_keys is to modify #SSH authorized_keys is in the format ssh-rsa key -
kaji-bikash created this gist
Jan 15, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #! /bin/bash #Assumptions #Default user deploy whose SSH authorized_keys is to modify #SSH authorized_keys is in the format ssh-rsa key home=${home:-deploy} username=$1 #get public key from a github KEY="https://github.com/$username.keys" curl --silent $KEY -o /tmp/$username.pub ssh_auth_file=`eval echo ~${home}/.ssh/authorized_keys` ##Append found keys to authorized_keys file while read line do echo $line >> ${ssh_auth_file} done <"/tmp/${username}.pub" #Simulate idempotence/de-duplication cat $ssh_auth_file | sort -u -k1,2 > ${ssh_auth_file}.uniq mv ${ssh_auth_file}.uniq ${ssh_auth_file}