Created
March 6, 2021 19:02
-
-
Save pipelinedave/e76f0f9090bb54d33409f5960defb21b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PS3='Select Environment: ' | |
options=("Local VM" "Other") | |
select opt in "${options[@]}" | |
do | |
case "$opt" in | |
"VirtualBox") | |
DISK=sda | |
PORT=2222 | |
HOST=127.0.0.1 | |
break | |
;; | |
"Other") | |
DISK=vda | |
PORT=22 | |
echo -n "HOST: " | |
read HOST | |
break | |
;; | |
*) echo Invalid;; | |
esac | |
done | |
echo DISK="$DISK", PORT="$PORT", HOST="$HOST" | |
HOST_ROOT="root@$HOST" | |
PUBKEY=$(cat ./id_rsa.pub) | |
# copy your public key, so can ssh without a password later on | |
ssh -tt -p "$PORT" "$HOST_ROOT" "mkdir -m 700 ~/.ssh; echo $PUBKEY > ~/.ssh/authorized_keys; chmod 600 ~/.ssh/authorized_keys" | |
# copy install scripts from ./root folder | |
scp -P "$PORT" ./root/* "$HOST_ROOT:/root" | |
# run the install script remotely | |
ssh -tt -p "$PORT" "$HOST_ROOT" "./install.sh $DISK" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment