blob: dce4ffc1d340b9ba51e421472c6ee5ea4ac80b77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import configparser
import subprocess
CONFIG = configparser.ConfigParser()
CONFIG.read("tunnel.conf")
cmd = ["autossh", "-nNTv", "-o", "StrictHostKeyChecking=no"]
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"))]
cmd.append(CONFIG.get("server", "host"))
print("Using command: " + " ".join(cmd))
subprocess.run(cmd)
|