summary refs log tree commit diff
path: root/diabloii-tunnel
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-12-15 11:41:35 -0600
committerStarfall <us@starfall.systems>2022-12-15 11:41:35 -0600
commit619f756e115948e95f0ae3e51f170fc79a558b29 (patch)
treeff20c83e3438000bfe1a7d21abf9a7e03f3acc29 /diabloii-tunnel
parent8985c5e9269308b75600e785147c196562fefe3f (diff)
diabloii-tunnel: port forward over ssh for diablo ii tcp/ip games
Diffstat (limited to 'diabloii-tunnel')
-rwxr-xr-xdiabloii-tunnel30
1 files changed, 30 insertions, 0 deletions
diff --git a/diabloii-tunnel b/diabloii-tunnel
new file mode 100755
index 0000000..bde7906
--- /dev/null
+++ b/diabloii-tunnel
@@ -0,0 +1,30 @@
+#!/usr/bin/env -S zsh -eu
+
+service=diabloii
+pubkey="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHVMEkZQ+dGB/wwc/Mo7Ejp8QXH9XpUWXKf7RixjBsJO minnow@regulus"
+port=4000
+
+echo "Creating user..."
+adduser --system --shell /bin/false --disabled-password $service
+
+echo "Creating .ssh directory..."
+mkdir                  /home/$service/.ssh
+chown $service:nogroup /home/$service/.ssh
+chmod 700              /home/$service/.ssh
+
+echo "Adding pubkey..."
+echo pubkey          > /home/$service/.ssh/authorized_keys
+chown $service:nogroup /home/$service/.ssh/authorized_keys
+chmod 600              /home/$service/.ssh/authorized_keys
+
+echo "Configuring firewall (ufw)..."
+ufw allow in $port/tcp comment "$service"
+
+echo "Configuring sshd..."
+echo ""                               >> /etc/ssh/sshd_config
+echo "Match User $service"            >> /etc/ssh/sshd_config
+echo "	GatewayPorts clientspecified" >> /etc/ssh/sshd_config
+
+echo "Done setting up ssh tunnel."
+echo "On your local machine, use this command to port forward:"
+echo "ssh -N -R :$port:localhost:$port $service@starfall.systems &"