2020-06-10 03:57:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-06-13 04:20:18 +00:00
|
|
|
ssh_command=""
|
2020-06-10 03:57:46 +00:00
|
|
|
|
|
|
|
check_key_file() {
|
2020-06-17 07:25:55 +00:00
|
|
|
key_file="$(find /tilde/key | tail -n1)"
|
2020-06-10 03:57:46 +00:00
|
|
|
if [ -f "$key_file" ]
|
|
|
|
then
|
2020-06-13 04:10:24 +00:00
|
|
|
while [ -z "$(cat $key_file | head -n1 | grep -- '-----BEGIN .* PRIVATE KEY-----')" ]
|
2020-06-10 03:57:46 +00:00
|
|
|
do
|
|
|
|
echo "$key_file does not look like a private key file, try again"
|
|
|
|
bash
|
|
|
|
done
|
2020-06-13 04:20:18 +00:00
|
|
|
ssh_command="ssh -i $key_file $tilde_username@$tilde_name"
|
2020-06-10 03:57:46 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
connection_test() {
|
2020-06-14 20:37:15 +00:00
|
|
|
while ! $ssh_command 'exit'
|
2020-06-10 03:57:46 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_user() {
|
|
|
|
mkdir "/home/$tilde_username"
|
2020-06-17 07:16:53 +00:00
|
|
|
useradd "$tilde_username" -d "/home/$tilde_username" -s /bin/bash
|
2020-06-10 03:57:46 +00:00
|
|
|
chown "$tilde_username:$tilde_username" "/home/$tilde_username"
|
2020-06-14 23:26:00 +00:00
|
|
|
echo "Mounting sshfs filesystem..."
|
2020-06-17 07:12:30 +00:00
|
|
|
sshfs "$tilde_username@$tilde_name":"/home/$tilde_username" "/home/$tilde_username" -o ssh_command="ssh -i $key_file" -o allow_other
|
2020-06-21 02:30:54 +00:00
|
|
|
mkdir '/etc/systemd/system/getty@tty1.service.d'
|
|
|
|
echo "[Service]" > '/etc/systemd/system/getty@tty1.service.d/override.conf'
|
|
|
|
echo "ExecStart=" >> '/etc/systemd/system/getty@tty1.service.d/override.conf'
|
|
|
|
echo "ExecStart=-/sbin/agetty --autologin $tilde_username %I $TERM" >> '/etc/systemd/system/getty@tty1.service.d/override.conf'
|
|
|
|
echo "Type=idle" >> '/etc/systemd/system/getty@tty1.service.d/override.conf'
|
2020-06-13 04:23:12 +00:00
|
|
|
# touch /usr/bin/sshshell
|
|
|
|
# echo "#!/bin/sh" >> /usr/bin/sshshell
|
|
|
|
# echo "ssh -i $key_file $tilde_username@$tilde_name" >> /usr/bin/sshshell
|
|
|
|
# chmod +x /usr/bin/sshshell
|
2020-06-14 23:26:00 +00:00
|
|
|
# echo "/usr/bin/sshshell" >> /etc/shells"
|
2020-06-13 04:23:12 +00:00
|
|
|
# chsh -s "/usr/bin/sshshell $tilde_username"
|
2020-06-10 03:57:46 +00:00
|
|
|
|
|
|
|
}
|
2020-06-14 23:41:44 +00:00
|
|
|
|
|
|
|
configure_network() {
|
|
|
|
echo "Press ENTER to configure network"
|
|
|
|
read dummy_var
|
|
|
|
nmtui
|
|
|
|
}
|