aboutsummaryrefslogtreecommitdiff
path: root/keyCheck.sh
blob: 2293b3c72970102c5c0c1fa305c405926488d2bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# Check for a public key, and create one for the user if it 
# does not exist. Spit the key in red to stdout

# Really useful for people running MacOS

# One line version to paste in a chat or so
# if [ -e ~/.ssh/id_rsa.pub ] ; then echo $'\033[1;31m' ; cat ~/.ssh/id_rsa.pub ; echo $'\033[0m' ; else ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -t rsa -P ""; echo $'\033[1;31m' ; cat ~/.ssh/id_rsa.pub ; echo $'\033[0m'; fi

if [ -e ~/.ssh/id_rsa.pub ] ; then 
	echo $'\033[1;31m' 
	cat ~/.ssh/id_rsa.pub 
	echo $'\033[0m' 
else 
	ssh-keygen \
		-t rsa \
		-b 4096 \
		-f ~/.ssh/id_rsa \
		-P ""
	echo $'\033[1;31m' 
	cat ~/.ssh/id_rsa.pub 
	echo $'\033[0m'
fi