Last active
December 17, 2021 09:01
-
-
Save royalgarter/af17af0d7da9e93c17b95ed88ae8c1ef to your computer and use it in GitHub Desktop.
Permanent autossh & screen with monitor & auto reconnect
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
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 [email protected]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment