-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_Plugin_SSH_auth.sh
More file actions
61 lines (49 loc) · 1.87 KB
/
set_Plugin_SSH_auth.sh
File metadata and controls
61 lines (49 loc) · 1.87 KB
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
#!/bin/bash
# Set filename to obtain ip address list for Plugin Node VPS's to setup wth SSH-key authentication
BASEFILE="user_at_ip"
# The plain ipaddresses file will be autogenerated from our BASEFILE further down
IPFILE="ip_addresses"
# Set Colour Vars
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo
echo
echo -e "${GREEN} #################################################### ${NC}"
echo -e "${GREEN} # # ${NC}"
echo -e "${GREEN} # SETUP SSH KEY-BASED AUTHENTICATION # ${NC}"
echo -e "${GREEN} # FOR MULTIPLE PLUGIN NODES # ${NC}"
echo -e "${GREEN} # # ${NC}"
echo -e "${GREEN} # Created by s4njk4n - https://github.com/s4njk4n/ #${NC}"
echo -e "${GREEN} # # ${NC}"
echo -e "${GREEN} #################################################### ${NC}"
echo
echo
echo -e "${RED}For each VPS you will be asked to enter the passwords for: ${NC}"
echo -e "${RED} - the ROOT user for that VPS; and then ${NC}"
echo -e "${RED} - also for the VPS username that the Plugin node was installed under ${NC}"
echo
echo -e "${RED}Your SSH-key will then be copied to both those users on the VPS. ${NC}"
echo
echo -e "${GREEN}Press any key to commence... ${NC}"
read -p " "
echo
echo -e "${GREEN}Generating plain IP address list ${NC}"
rm $IPFILE > /dev/null 2>&1
cut -d "@" -f 2 $BASEFILE > $IPFILE
echo
echo
paste -d "@" $IPFILE $BASEFILE | while IFS="@" read -r f1 f2
do
echo
echo -e "${GREEN}Setting up SSH key-based authentication for $f1 ${NC}"
echo
ssh-copy-id -o "StrictHostKeyChecking=no" root@$f1
echo
ssh-copy-id -o "StrictHostKeyChecking=no" $f2
echo
done
rm $IPFILE
echo
echo -e "${RED}SSH KEY-BASED AUTHENTICATION ESTABLISHED FOR ALL PLUGIN NODES ${NC}"
echo