aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Containerfile4
-rwxr-xr-xdbx3
-rwxr-xr-xdbx-enter2
-rwxr-xr-xdbx-proxy17
-rw-r--r--ssh/config.in2
6 files changed, 26 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 006e32b..0f8e6ab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@ custom/extra-packages
custom/post-install
custom/skel/
ssh/*.config
+ssh/*.known_hosts
ssh/id_*
diff --git a/Containerfile b/Containerfile
index 24698e9..9f250dd 100644
--- a/Containerfile
+++ b/Containerfile
@@ -7,6 +7,7 @@ RUN touch /run/.dbxenv
RUN rm /etc/apt/apt.conf.d/docker-* && \
apt-get update && \
apt-get install -y \
+ locales \
openssh-server \
sudo \
tini \
@@ -14,6 +15,9 @@ RUN rm /etc/apt/apt.conf.d/docker-* && \
apt-get clean && \
rm -dr /var/lib/apt/lists/*
+# Configure locale with UTF-8 support
+RUN update-locale LANG=C.UTF-8 LC_ALL=C.UTF-8
+
# Configure SSH server
COPY ssh/id_ed25519.pub /etc/ssh/authorized_keys
RUN echo "StreamLocalBindUnlink yes" >> /etc/ssh/sshd_config && \
diff --git a/dbx b/dbx
index 993ddda..3402133 100755
--- a/dbx
+++ b/dbx
@@ -13,6 +13,7 @@ dbx - containerized development environments
USAGE:
dbx create creates the devbox
dbx [enter] enters the devbox
+ dbx proxy PORT proxies a devbox port to the host
dbx start starts the devbox
dbx stop stops the devbox
EOF
@@ -22,7 +23,7 @@ cmd="${1:-enter}"
shift || true
case "$#:$cmd" in
- 0:create|0:enter|0:start|0:stop)
+ 0:create|0:enter|1:proxy|0:start|0:stop)
"$root/dbx-$cmd" "$@"
;;
*)
diff --git a/dbx-enter b/dbx-enter
index 88db503..49078b4 100755
--- a/dbx-enter
+++ b/dbx-enter
@@ -8,4 +8,4 @@ root="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
machine="${DBX_MACHINE:-dbx}"
"$root/dbx-start"
-exec ssh -F "$root/ssh/$machine.config" "$machine"
+exec ssh "$machine" -F "$root/ssh/$machine.config"
diff --git a/dbx-proxy b/dbx-proxy
new file mode 100755
index 0000000..67e0456
--- /dev/null
+++ b/dbx-proxy
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-3.0-only
+
+set -euo pipefail
+
+if [[ $# -ne 1 ]]; then
+ echo "ERROR: missing port to proxy" >&2
+ exit 1
+fi
+
+root="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
+machine="${DBX_MACHINE:-dbx}"
+port="$1"
+
+"$root/dbx-start"
+exec ssh "$machine" -F "$root/ssh/$machine.config" \
+ -L "localhost:$port:localhost:$port" -N
diff --git a/ssh/config.in b/ssh/config.in
index 294754e..fbcbc40 100644
--- a/ssh/config.in
+++ b/ssh/config.in
@@ -3,4 +3,4 @@ Host $MACHINE
IdentitiesOnly yes
IdentityFile $ROOT/ssh/id_ed25519
StrictHostKeyChecking no
- UserKnownHostsFile /dev/null
+ UserKnownHostsFile $ROOT/ssh/$MACHINE.known_hosts