aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2022-02-25 20:58:06 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2022-02-25 20:58:06 +0000
commitb277af9cb84c7f42c088f17ed0036bda6aeacdf4 (patch)
treefbff39db45995a063cd3565d149661f0e5ec3cd6
parent0c284f018029b102c536068689248fa6e8c0d424 (diff)
downloadReverseSSHTunnel-b277af9cb84c7f42c088f17ed0036bda6aeacdf4.tar.gz
ReverseSSHTunnel-b277af9cb84c7f42c088f17ed0036bda6aeacdf4.zip
added dockerfiles
-rw-r--r--.gitignore4
-rw-r--r--Dockerfile8
-rw-r--r--docker-compose.yml12
-rw-r--r--tunnel.conf1
-rw-r--r--tunnel.py6
5 files changed, 29 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index d9005f2..b66cfd9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
-# Byte-compiled / optimized / DLL files
+*.pem
+
+# Byte-compiled / optimized / DLL file
__pycache__/
*.py[cod]
*$py.class
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..adeea16
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,8 @@
+FROM ubuntu:latest
+MAINTAINER Eden Attenborough "eddie.atten.ea29@gmail.com"
+RUN apt-get update -y
+RUN apt-get install -y autossh python3-pip python-dev build-essential
+COPY . /app
+WORKDIR /app
+ENTRYPOINT ["python3"]
+CMD ["tunnel.py"]
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..581f78c
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,12 @@
+version: '3'
+
+services:
+ tunnel:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ image: jwansek/reversesshtunnel
+ network_mode: host
+ volumes:
+ - ./vps.pem:/app/vps.pem
+ - ./tunnel.conf:/app/tunnel.conf
diff --git a/tunnel.conf b/tunnel.conf
index 87998ed..b6a01b3 100644
--- a/tunnel.conf
+++ b/tunnel.conf
@@ -1,6 +1,7 @@
[server]
host = vps.eda.gay
ssh_port = 2222
+keyfile = vps.pem
[forward-eda.gay]
from = 192.168.1.92:6969
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)