Alysha Creelman
commited on
Create key_setup_groupkey.sh
Browse files- key_setup_groupkey.sh +73 -0
key_setup_groupkey.sh
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#! /bin/bash
|
2 |
+
|
3 |
+
PORT=22003
|
4 |
+
MACHINE=paffenroth-23.dyn.wpi.edu
|
5 |
+
|
6 |
+
# Clean up from previous runs
|
7 |
+
ssh-keygen -f "/home/amcreelman/.ssh/known_hosts" -R "[${MACHINE}]:${PORT}"
|
8 |
+
rm -rf tmp2
|
9 |
+
|
10 |
+
# Create a temporary directory
|
11 |
+
mkdir tmp2
|
12 |
+
|
13 |
+
# copy the key to the temporary directory
|
14 |
+
cp wormington_keys/group_key* tmp2
|
15 |
+
|
16 |
+
# copy the key to the temporary directory
|
17 |
+
cp wormington_keys/group_key* tmp2
|
18 |
+
|
19 |
+
# Change to the temporary directory
|
20 |
+
cd tmp2
|
21 |
+
|
22 |
+
# Set the permissions of the key
|
23 |
+
chmod 600 group_key*
|
24 |
+
|
25 |
+
# Set the permissions of the key
|
26 |
+
chmod 600 group_key*
|
27 |
+
|
28 |
+
# skip creating unique key -- already have
|
29 |
+
|
30 |
+
# Insert the key into the authorized_keys file on the server
|
31 |
+
# One > creates
|
32 |
+
cat group_key.pub > authorized_keys
|
33 |
+
# two >> appends
|
34 |
+
# Remove to lock down machine
|
35 |
+
#cat group_key.pub >> authorized_keys
|
36 |
+
|
37 |
+
chmod 600 authorized_keys
|
38 |
+
|
39 |
+
echo "checking that the authorized_keys file is correct"
|
40 |
+
ls -l authorized_keys
|
41 |
+
cat authorized_keys
|
42 |
+
|
43 |
+
# Copy the authorized_keys file to the server
|
44 |
+
scp -i group_key -P ${PORT} -o StrictHostKeyChecking=no authorized_keys student-admin@${MACHINE}:~/.ssh/
|
45 |
+
|
46 |
+
# Add the key to the ssh-agent
|
47 |
+
eval "$(ssh-agent -s)"
|
48 |
+
ssh-add group_key
|
49 |
+
|
50 |
+
# entered our password
|
51 |
+
|
52 |
+
# Check the key file on the server
|
53 |
+
echo "checking that the authorized_keys file is correct"
|
54 |
+
ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE} "cat ~/.ssh/authorized_keys"
|
55 |
+
|
56 |
+
# clone the repo
|
57 |
+
git clone https://github.com/alyshacreelman/Wormington-Scholar
|
58 |
+
|
59 |
+
# Copy the files to the server
|
60 |
+
scp -P ${PORT} -o StrictHostKeyChecking=no -r Wormington-Scholar student-admin@${MACHINE}:~/
|
61 |
+
|
62 |
+
# from here on code is currently commented out in Randy's code
|
63 |
+
|
64 |
+
# check that the code in installed and start up the product
|
65 |
+
COMMAND="ssh -p ${PORT} -o StrictHostKeyChecking=no student-admin@${MACHINE}"
|
66 |
+
|
67 |
+
${COMMAND} "ls Wormington-Scholar"
|
68 |
+
${COMMAND} "sudo apt install -qq -y python3-venv"
|
69 |
+
${COMMAND} "cd Wormington-Scholar && python3 -m venv venv"
|
70 |
+
${COMMAND} "cd Wormington-Scholar && source venv/bin/activate && pip install -r requirements.txt"
|
71 |
+
${COMMAND} "nohup Wormington-Scholar/venv/bin/python3 Wormington-Scholar/app.py > log.txt 2>&1 &"
|
72 |
+
|
73 |
+
# nohup ./whatever > /dev/null 2>&1
|