This repository has been archived by the owner on Jan 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
remote-install.sh
executable file
·53 lines (37 loc) · 2.35 KB
/
remote-install.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
###################################################################################################
# CONFIGURATION
###################################################################################################
SERVER_DOMAIN="<domain of ubuntu server>"
SUDO_USER_NAME="<name of to be created sudo user>"
SUDO_USER_PWD="<password of to be created sudo user>"
IS_MAC=true
# use with caution. If you want to revoke your decission later, you manually need to edit /etc/ssh/sshd_config
DISABLE_ROOT_LOGIN=false
DISABLE_ROOT_PASSWORD_LOGIN=false
###################################################################################################
# DEFINES
###################################################################################################
KNOWN_HOSTS_FILE_PATH="/home/$(whoami)/.ssh/known_hosts"
CREATE_SUDO_USER_SCRIPT_NAME="create-sudo-user.sh"
INSTALL_ARDOR_SCRIPT_NAME="install-ardor.sh"
INSTALL_ARDOR_SCRIPT_PATH=$(dirname `which $0`)
CREATE_SUDO_USER_CMD="chmod 700 ${CREATE_SUDO_USER_SCRIPT_NAME} && ./${CREATE_SUDO_USER_SCRIPT_NAME} -u ${SUDO_USER_NAME} -p ${SUDO_USER_PWD}"
DISABLE_ROOT_LOGIN_CMD='sed -i -e "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config'
DISABLE_ROOT_PASSWORD_LOGIN_CMD='sed -i -e "s/PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config'
###################################################################################################
# MAIN
###################################################################################################
if [ ${IS_MAC} == true ]; then
ssh-keygen -R ${SERVER_DOMAIN}
else
ssh-keygen -f ${KNOWN_HOSTS_FILE_PATH} -R ${SERVER_DOMAIN}
fi
SERVER_ACCESS_CMD=""
if [ ${DISABLE_ROOT_LOGIN} == true ]; then SERVER_ACCESS_CMD="${DISABLE_ROOT_LOGIN_CMD} && "; fi
if [ ${DISABLE_ROOT_PASSWORD_LOGIN} == true ]; then SERVER_ACCESS_CMD="${SERVER_ACCESS_CMD}${DISABLE_ROOT_PASSWORD_LOGIN_CMD} && "; fi
SERVER_ACCESS_CMD="${SERVER_ACCESS_CMD}${CREATE_SUDO_USER_CMD}"
scp ./${CREATE_SUDO_USER_SCRIPT_NAME} root@${SERVER_DOMAIN}: | tee log.txt
ssh -t root@${SERVER_DOMAIN} "${SERVER_ACCESS_CMD}" | tee -a log.txt
scp ${INSTALL_ARDOR_SCRIPT_PATH}/${INSTALL_ARDOR_SCRIPT_NAME} ${SUDO_USER_NAME}@${SERVER_DOMAIN}: | tee -a log.txt
ssh -t ${SUDO_USER_NAME}@${SERVER_DOMAIN} "chmod 700 ${INSTALL_ARDOR_SCRIPT_NAME} && ./${INSTALL_ARDOR_SCRIPT_NAME}" | tee -a log.txt