Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

ssh tunnel added based on https://github.com/cagataygurturk/docker-ssh-tunnel #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ LABEL org.opencontainers.image.version="$IMAGE_VERSION"
ENV KILL_SWITCH=on \
VPN_LOG_LEVEL=3 \
HTTP_PROXY=off \
SOCKS_PROXY=off
SOCKS_PROXY=off \
SSH_TUNNEL=off

RUN apk add --no-cache \
bash \
bind-tools \
dante-server \
openvpn \
tinyproxy
tinyproxy \
openssh

RUN mkdir -p /data/vpn
RUN mkdir -p /data/vpn \
/data/ssh

COPY data/ /data

Expand Down
5 changes: 5 additions & 0 deletions data/scripts/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ echo "
Kill switch: ${KILL_SWITCH:-off}
HTTP proxy: ${HTTP_PROXY:-off}
SOCKS proxy: ${SOCKS_PROXY:-off}
SSH tunnel: ${SSH_TUNNEL:-off}
Keep /etc/resolv.conf unchanged: ${KEEP_DNS_UNCHANGED:-no}
Proxy username secret: ${PROXY_PASSWORD_SECRET:-none}
Proxy password secret: ${PROXY_USERNAME_SECRET:-none}
Expand Down Expand Up @@ -212,6 +213,10 @@ if [[ "$SOCKS_PROXY" == "on" ]]; then
/data/scripts/dante_wrapper.sh &
fi

if [[ "$SSH_TUNNEL" == "on" ]]; then
/data/scripts/sshtunnel_wrapper.sh &
fi

openvpn_args=(
"--config" "$config_file_modified"
"--auth-nocache"
Expand Down
17 changes: 17 additions & 0 deletions data/scripts/sshtunnel_wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

echo -e "Running SSH Tunnel.\n"

until ip link show tun0 2>&1 | grep -qv "does not exist"; do
sleep 1
done

passwd -d root
adduser -D -s /bin/ash tunnel
passwd -d tunnel
chown -R tunnel:tunnel /home/tunnel
ssh-keygen -A
mkdir /home/tunnel/.ssh
cp /data/ssh/id_rsa.pub /home/tunnel/.ssh/authorized_keys

/usr/sbin/sshd -D