forked from Aplyca/development-environment-setup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_git.sh
26 lines (24 loc) · 827 Bytes
/
configure_git.sh
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
#!/usr/bin/env bash
echo "Enter the following to configure Git with SSH key pair"
echo "Your name:"
read name;
echo "Your email:"
read email;
echo "Git remote host:"
read host;
echo "Local key name:"
read key;
if [ -z "${name}" ] || [ -z "${email}" ]; then
echo "Git config not setted, keeping the current.";
else
git config --global user.name "$name";
git config --global user.email "$email";
fi
if [ -z "${host}" ] || [ -z "${key}" ]; then
echo "SSH key not set";
else
ssh-keygen -t rsa -b 4096 -C "$email" -f ~/.ssh/$key.key -N "" -P "";
printf "\nHost $host\n HostName $host\n User git\n IdentityFile ~/.ssh/$key.key\n StrictHostKeyChecking no\n" >> ~/.ssh/config;
xclip -selection clipboard < ~/.ssh/$key.key.pub;
echo "Your public key (~/.ssh/$key.key.pub) was copied to your clipboard";
fi