Setup and keep alive ssh tunnels to remote sites using autossh, screen.
- autossh
- screen
-
Sites to tunnel to are configured in
~/.ssh/config
:Host
declarations that start with 'autossh-' in the name are detected as candidates for tunnel sites. Example:Host autossh-HOSTNAME Hostname HOSTNAME User USER RemoteForward 8022 localhost:22 IdentityFile ~/.ssh/autossh-id_rsa
-
ssh-keygen.sh
: helper script to generate an SSH key without passphrase. Note: for added security, the public key is configured with the following options:command="/bin/false",no-agent-forwarding,no-X11-forwarding,no-pty
-
ssh-copy-id.sh
: helper script to install SSH key in~/.ssh/authorized_keys
on each of the detected tunnel sites -
setup.sh
:Print the details of the detected setup:
- SSH key that will be used with
autossh
- Detected tunnel sites in
~/.ssh/config
- Confirmed tunnel sites (accepting the SSH key)
Print the steps to complete the configuration.
Print tips how to test the configuration.
- SSH key that will be used with
-
autossh.sh
: runautossh
for each detected site in an independentscreen
session, unless already running -
Add to
crontab
a line like this to periodically runautossh.sh
:0 * * * * AUTOSSH_PORT=0 $PWD/autossh.sh
Simply run ./setup.sh
and follow the steps. This script does not
do anything. It only tells you the configuration it detected and
gives you the steps you need to follow to complete the configuration.
- Remove any
cron
jobs runningautossh.sh
./stop.sh
to stop any runningautossh
andscreen
instances- Login to each tunnel site and manually remove the script's SSH key
from
~/.ssh/authorized_keys