aboutsummaryrefslogtreecommitdiffstats
path: root/tunnel.py
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel.py')
-rw-r--r--tunnel.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tunnel.py b/tunnel.py
index b8e7540..161030f 100644
--- a/tunnel.py
+++ b/tunnel.py
@@ -4,11 +4,14 @@ import subprocess
CONFIG = configparser.ConfigParser()
CONFIG.read("tunnel.conf")
-cmd = ["ssh", "-nNTv"]
+cmd = ["autossh", "-nNTv"]
if CONFIG.has_option("server", "ssh_port"):
cmd += ["-p", CONFIG.get("server", "ssh_port")]
+if CONFIG.has_option("server", "keyfile"):
+ cmd += ["-i", CONFIG.get("server", "keyfile")]
+
for section in CONFIG.sections():
if section.startswith("forward"):
cmd += ["-R", "%s:%s" % (CONFIG.get(section, "to"), CONFIG.get(section, "from"))]
@@ -16,3 +19,4 @@ for section in CONFIG.sections():
cmd.append(CONFIG.get("server", "host"))
print("Using command: " + " ".join(cmd))
+subprocess.run(cmd)