TIL how to run SSH tunnels in Bash scripts
2025-03-05 • 2 mins

To run a SSH tunnel in a Bash script or a CI job, we can utilize the following command:

ssh -o ExitOnForwardFailure=yes -f -L port:host:5432 user@$ip -i ~/.ssh/key.pub sleep 10

# Use Cases

Some examples of use cases:

# References

Edited: 2025-06-11