-
Notifications
You must be signed in to change notification settings - Fork 23
/
create-ssh-key.sh
executable file
·42 lines (30 loc) · 1.31 KB
/
create-ssh-key.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
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
TAG="[$(basename -- "$0")]"
usage="Usage: COMPANY={VALUE} PROJECT={VALUE} EMAIL={VALUE} $0"
COMPANY=${COMPANY:=}
PROJECT=${PROJECT:=}
EMAIL=${EMAIL:=}
company=$(echo ${COMPANY} | tr '[:upper:]' '[:lower:]')
project=$(echo ${PROJECT} | tr '[:upper:]' '[:lower:]')
function validate {
if [ "z${PROJECT}" == "z" ] || [ "z${PROJECT}" == "z" ] || [ "z${EMAIL}" == "z" ]; then
echo ${usage}
exit 1
fi
echo -e "${TAG} PROJECT=${PROJECT} PROJECT=${PROJECT}"
}
echo -e ""
echo -e "${TAG} Generating SSH Key Pair"
ssh-keygen -t rsa -b 4096 -N '' -C "${EMAIL}" -f "key.${project}.${company}.io_rsa"
mv key.${project}.${company}.io_rsa ~/.ssh/
mv key.${project}.${company}.io_rsa.pub ~/.ssh/
echo -e ""
echo -e "${TAG} Listing SSH Key Pair under '~/.ssh/'"
ls ~/.ssh | grep key.${project}.${company}.io_rsa
echo -e ""
echo -e "${TAG} Replace 'company' and 'project' variable.customize.tf"
sed -i.bak "s/ default = \"[a-zA-Z0-9_]*\" # company/ default = \"${company}\" # company/" root-infra/variable.customize.tf
sed -i.bak "s/ default = \"[a-zA-Z0-9_]*\" # project/ default = \"${project}\" # project/" root-infra/variable.customize.tf
rm -rf root-infra/variable.customize.tf.bak
cat root-infra/variable.customize.tf | grep "# company"
cat root-infra/variable.customize.tf | grep "# project"