-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssh-setup
executable file
·102 lines (90 loc) · 2.34 KB
/
ssh-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/bash
# A script that automates the ssh key generation and copies the pub file to your clipboard
EXIT_SUCCESS=0
EXIT_FAILURE=1
SUCCESS=1
cont=true
PROGRAM_NAME=$(echo $basename $0)
ssh_setup()
{
get_user_info
create_ssh_keys
copy_ssh_pub_to_clipboard
setup_git_config
exit ${EXIT_SUCCESS}
}
get_user_info()
{
while [[ $cont == true ]]
do
read -r -p "Enter Your Email Address: " email
read -r -p "Is this correct? y/[N] --> ${email}: " response
is_correct_email=[Yy]
if [[ $response = $is_correct_email ]];then
cont=false
fi
done
return ${SUCCESS}
}
create_ssh_keys()
{
ssh-keygen -t ed25519 -C \"$email\"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
return ${SUCCESS}
}
copy_ssh_pub_to_clipboard()
{
echo "******************************************************"
read -r -p "Which distro do you have? ([a]rch or [d]ebian): " distro
echo "******************************************************"
case $distro in
[aA] | [aA]rch)
sudo pacman -S xclip
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
;;
[dD] | [dD]ebian)
sudo apt install xclip
xclip -selection clipboard < ~/.ssh/id_ed25519.pub
;;
*)
echo "Please Select Either ARCH or DEBIAN Next Time"
wait 2
;;
esac
return ${SUCCESS}
}
setup_git_config()
{
echo "**********************************"
read -r -p "What is your First Name? " first_name
read -r -p "What is your Last Name? " last_name
echo "**********************************"
echo "**********************************"
echo "Public Key copied to clipboard..."
echo "**********************************"
echo "**********************************"
echo -e "Go paste that key into Github, then copy the following to your terminal.\n"
git config --global user.email $email
git config --global user.name "$first_name $last_name"
return ${SUCCESS}
}
print_help_message()
{
echo -e "\
USAGE $PROGRAM_NAME
DESCRIPTION
A program that sets SSH up on your computer.
"
}
case $1 in
"")
ssh_setup
exit $EXIT_SUCCESS
;;
-h | --help | *)
print_help_message
exit $EXIT_SUCCESS
;;
esac
ssh_setup