tl-setup/connection.sh

42 lines
966 B
Bash
Executable File

#!/bin/sh
connection_test() {
ssh_command="$1"
while ! $ssh_command 'exit'
do
echo "There seems to be a problem connecting to the tilde"
echo "Use this shell to try and fix any problems, then try connecting again by exiting the shell"
bash
done
echo "Connection success!"
}
check_key_file() {
ssh_command=""
chmod 700 /tilde/key/*
tilde_username="$1"
tilde_name="$2"
key_file="$(find /tilde/key | tail -n1)"
if [ -f "$key_file" ]
then
while [ -z "$(cat $key_file | head -n1 | grep -- '-----BEGIN .* PRIVATE KEY-----')" ]
do
echo "$key_file does not look like a private key file, try again"
key_file="$(find /tilde/key | tail -n1)"
bash
done
ssh_command="ssh -i $key_file $tilde_username@$tilde_name"
echo "Key file located!"
fi
echo "Testing ssh connection to $tilde_name as user $tilde_username..."
connection_test "$ssh_command"
}
configure_network() {
echo "Press ENTER to configure network"
read dummy_var
nmtui
}