blob: 161030f013ae904d6cf31b51493d38d616c4fb00 (
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"]
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)
|