pinkeen.ssh-tunnel-client
Creating Persistent SSH Tunnels with Autossh (CentOS 7)
ssh_tunnel_client_user
: Default value isssh_tunnel
.ssh_tunnels
: An array that contains:name
: The name used to identify services.key_file
: Your private SSH key.target_host
: This is required.target_port
: This is required.local_port
: This is required.remote_user
: By default, this is set tossh_tunnel
.alive_interval
: Default value is10
.alive_count_max
: Default value is1
.
Important Note
Autossh uses a monitoring port on the remote machine. Since a specific port is used, multiple clients cannot use the same port at the same time, which causes the SSH session to restart every 10 minutes.
Currently, the option for port randomization does not work in the latest version of CentOS 7 (1.4e) as of this writing.
Therefore, monitoring with Autossh is disabled.
Even without monitoring, it should still work well, because SSH will exit quickly if there’s no connection due to the options -oServerAliveInterval=60 -oServerAliveCountMax=2
.
For more information, visit: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=351162
Side Note:
You might wonder why you need Autossh if systemd can handle restarting the sessions.
ansible-galaxy install pinkeen.ssh-tunnel-client