mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-10 06:03:47 -05:00
First commit
This commit is contained in:
37
setupScripts/ssh.sh
Executable file
37
setupScripts/ssh.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This script creates public SSH Keys and sends them to Github
|
||||
|
||||
if [ -f "../lib/utils.sh" ]; then
|
||||
source "../lib/utils.sh"
|
||||
else
|
||||
echo "You must have utils.sh to run. Exiting."
|
||||
exit
|
||||
fi
|
||||
|
||||
e_header "Running : SSH CONFIG"
|
||||
|
||||
e_success "Checking for SSH key in ~/.ssh/id_rsa.pub, generating one if it doesn't exist ..."
|
||||
[[ -f ~/.ssh/id_rsa.pub ]] || ssh-keygen -t rsa
|
||||
|
||||
e_success "Copying public key to clipboard."
|
||||
[[ -f ~/.ssh/id_rsa.pub ]] && cat ~/.ssh/id_rsa.pub | pbcopy
|
||||
|
||||
# Add SSH keys to Github
|
||||
e_header "Github integration"
|
||||
seek_confirmation "Open https://github.com/account/ssh in your browser?"
|
||||
if is_confirmed; then
|
||||
e_success "Copying public key to clipboard."
|
||||
|
||||
[[ -f ~/.ssh/id_rsa.pub ]] && cat ~/.ssh/id_rsa.pub | pbcopy
|
||||
|
||||
open https://github.com/account/ssh
|
||||
|
||||
seek_confirmation "Test Github Authentication via ssh?"
|
||||
if is_confirmed; then
|
||||
printf "\n Testing..."
|
||||
ssh -T git@github.com
|
||||
fi
|
||||
fi
|
||||
|
||||
e_header "Completed : SSH CONFIG"
|
||||
Reference in New Issue
Block a user