Skip to content

Instantly share code, notes, and snippets.

@royalgarter
Last active December 17, 2021 09:01
Show Gist options
  • Save royalgarter/af17af0d7da9e93c17b95ed88ae8c1ef to your computer and use it in GitHub Desktop.
Save royalgarter/af17af0d7da9e93c17b95ed88ae8c1ef to your computer and use it in GitHub Desktop.
Permanent autossh & screen with monitor & auto reconnect
sudo apt update
sudo apt install autossh -f
#echo -e "alias assh='f(){ autossh -M 22222 \$@ -t \"screen -DRR autossh\"; unset -f f; }; f'" >> ~/.bashrc
echo -e "alias assh='f(){ X=\$@;while true; do p=\$(shuf -i 2000-65000 -n 1);netstat -lat | grep \$p; if [[ \$? == 1 ]] ; then autossh -M \$p \$X -t \"screen -DRR autossh\"; break; fi; done; unset -f f; }; f'" >> ~/.bashrc
source ~/.bashrc
echo -e "Using:\n assh root@yourremotepc.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment