Skip to content

Set up a persistent tunnel (using autossh) in Ubuntu systems (client side)

License

Notifications You must be signed in to change notification settings

Oefenweb/ansible-autossh-tunnel-client

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bec110a · Oct 19, 2024
Jan 10, 2023
Mar 15, 2021
Aug 14, 2015
Jul 19, 2022
Jul 19, 2022
Sep 20, 2023
Sep 20, 2023
Jun 19, 2020
Sep 20, 2023
Mar 15, 2021
Mar 30, 2023
Aug 14, 2015
Feb 4, 2021
Jul 19, 2022
Aug 14, 2015
Oct 19, 2024
Feb 4, 2021
Jul 19, 2022

Repository files navigation

autossh-tunnel-client

CI Ansible Galaxy

Set up a persistent tunnel (using autossh) in Ubuntu systems (client side).

Requirements

None

Variables

  • autossh_tunnel_client_autossh_debug: [default: 1]: If this variable is set, the logging level is set to LOG_DEBUG

  • autossh_tunnel_client_autossh_first_poll: [default: 30]: Specifies the time to wait before the first connection test

  • autossh_tunnel_client_autossh_gatetime: [default: 0]: Specifies how long ssh must be up before we consider it a successful connection. If it is set to 0, then not only is the gatetime behaviour turned off, but autossh also ignores the first run failure of ssh

  • autossh_tunnel_client_autossh_loglevel: [default: 7]: Specifies the log level, corresponding to the levels used by syslog

  • autossh_tunnel_client_autossh_pidfile: [default: /var/run/autossh/autossh-tunnel-client.pid]: Write pid to specified file

  • autossh_tunnel_client_autossh_poll: [default: 60]: Specifies the connection poll time in seconds

  • autossh_tunnel_client_key_map: [default: []]: SSH key declarations

  • autossh_tunnel_client_key_map.{n}.src: [optional]: The path of the file to copy, can be absolute or relative (e.g. ../../../files/autossh-tunnel-client/etc/autossh/id_rsa)

  • autossh_tunnel_client_key_map.{n}.remote_src: [optional, default false]: Whether the src is on the remote

  • autossh_tunnel_client_key_map.{n}.dest: [optional, default src | basename]: The remote path of the file to copy, relative to /etc/autossh (e.g. id_rsa)

  • autossh_tunnel_client_key_map.{n}.owner: [optional, default root]: The name of the user that should own the file

  • autossh_tunnel_client_key_map.{n}.group: [optional, default owner, root]: The name of the group that should own the file

  • autossh_tunnel_client_key_map.{n}.mode: [optional, default 0600]: The mode of the file to copy

  • autossh_tunnel_client_host: [required] Remote host to connect to (e.g. example.com)

  • autossh_tunnel_client_port: [default: 22]: Remote port to connect to

  • autossh_tunnel_client_user: [default: autossh]: Remote user for connection

  • autossh_tunnel_client_identity: [default: id_rsa]: Remote user for connection

  • autossh_tunnel_client_autossh_options: [default: ['M 0', '4', 'N']]: Autossh options

  • autossh_tunnel_client_ssh_options: [default: ['ServerAliveInterval 60', 'ServerAliveCountMax 3', 'BatchMode=yes', 'StrictHostKeyChecking=no']]: SSH options

  • autossh_tunnel_client_forward: [required]: Port forward to set up (e.g. ['3307:127.0.0.1:3306'])

  • autossh_tunnel_client_forward_direction: [default: L]: Specifies the direction of the tunnel. If it is set to R, then the direction of the tunnel is reversed making it into a reverse ssh tunnel

Dependencies

None

Recommended

  • ansible-autossh-tunnel-server (see)

Example(s)

MySQL tunnel
---
- hosts: all
  roles:
    - oefenweb.autossh-tunnel-client
  vars:
    autossh_tunnel_client_key_map:
      - src: ../../../files/autossh-tunnel-client/etc/autossh/id_rsa
    autossh_tunnel_client_host: 'example.com'
    autossh_tunnel_client_forward: ['3307:127.0.0.1:3306']

You will be able to connect to mysql using:

mysql -h 127.0.0.1 -P 3307 -u#### -p#### --skip-ssl;

License

MIT

Author Information

Mischa ter Smitten (based on work of netkernelroc)

Feedback, bug-reports, requests, ...

Are welcome!