Starts an SSH tunnel in the background and checks if it is usable. Can be used in a Github action e.g. in order to connect to a Postgres instance that is only reachable via SSH.
You need to set the following env variables
Variable | Description |
---|---|
SSH_TUNNEL_HOST |
The hostname of the machine, e.g. example.com |
SSH_TUNNEL_PORT |
The SSH port you want to connect to (e.g. 22 ) |
SSH_TUNNEL_USER |
The SSH user, e.g. root |
SSH_TUNNEL_PRIVATE_KEY |
The private key you are going to use for ssh |
SSH_TUNNEL_HOST_PUBLIC_KEYS |
Public keys of the host that will be appended to known_hosts . Necessary to prevent MITM attacks. Use ssh-keyscan $SSH_TUNNEL_HOST to get the keys. |
SSH_TUNNEL_LOCAL_PORT |
The local port you want to open |
SSH_TUNNEL_REMOTE_HOST |
The hostname you want to connect to from SSH_TUNNEL_HOST |
SSH_TUNNEL_REMOTE_PORT |
The port you want to connect to at SSH_TUNNEL_REMOTE_HOST |
The script is going to exit with code 0 as soon as SSH_TUNNEL_LOCAL_PORT
is usable on localhost
.