From 0c284f018029b102c536068689248fa6e8c0d424 Mon Sep 17 00:00:00 2001 From: jwansek Date: Fri, 25 Feb 2022 20:16:15 +0000 Subject: added configuration file and script example --- tunnel.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tunnel.py (limited to 'tunnel.py') diff --git a/tunnel.py b/tunnel.py new file mode 100644 index 0000000..b8e7540 --- /dev/null +++ b/tunnel.py @@ -0,0 +1,18 @@ +import configparser +import subprocess + +CONFIG = configparser.ConfigParser() +CONFIG.read("tunnel.conf") + +cmd = ["ssh", "-nNTv"] + +if CONFIG.has_option("server", "ssh_port"): + cmd += ["-p", CONFIG.get("server", "ssh_port")] + +for section in CONFIG.sections(): + if section.startswith("forward"): + cmd += ["-R", "%s:%s" % (CONFIG.get(section, "to"), CONFIG.get(section, "from"))] + +cmd.append(CONFIG.get("server", "host")) + +print("Using command: " + " ".join(cmd)) -- cgit v1.2.3