aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2022-02-25 20:16:15 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2022-02-25 20:16:15 +0000
commit0c284f018029b102c536068689248fa6e8c0d424 (patch)
tree405b7092701dcfa3ded95a203db46055e18af20b
parent6f437c6c981575d3ab33c37e3041a5177c094e15 (diff)
downloadReverseSSHTunnel-0c284f018029b102c536068689248fa6e8c0d424.tar.gz
ReverseSSHTunnel-0c284f018029b102c536068689248fa6e8c0d424.zip
added configuration file and script example
-rw-r--r--tunnel.conf11
-rw-r--r--tunnel.py18
2 files changed, 29 insertions, 0 deletions
diff --git a/tunnel.conf b/tunnel.conf
new file mode 100644
index 0000000..87998ed
--- /dev/null
+++ b/tunnel.conf
@@ -0,0 +1,11 @@
+[server]
+host = vps.eda.gay
+ssh_port = 2222
+
+[forward-eda.gay]
+from = 192.168.1.92:6969
+to = 0.0.0.0:6969
+
+[forward-invidious]
+from = 192.168.1.92:3000
+to = 0.0.0.0:3000
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))