From a0ee6db7e567c0cbf34fc2e21d799f9df2c01949 Mon Sep 17 00:00:00 2001 From: Matthew Faltys Date: Wed, 13 Nov 2019 16:53:55 +0000 Subject: [PATCH] Add openssh with hack login to docker container --- deps/Dockerfile | 10 ++++++++++ deps/run.sh | 4 ++++ nethack-launcher.go | 1 - 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/deps/Dockerfile b/deps/Dockerfile index d058edb..cb13b4f 100644 --- a/deps/Dockerfile +++ b/deps/Dockerfile @@ -6,6 +6,7 @@ RUN apt-get update && \ ttyrec \ nethack-console \ redis-server \ + openssh-server \ vim # make required dirs @@ -15,6 +16,15 @@ RUN mkdir -p /redisbackup/ RUN mv /usr/games/nethack /bin/nethack RUN mkdir /hack/ +# update ssh config +RUN echo "AllowUsers hack" >> /etc/ssh/sshd_config +RUN echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config + +# add hack user +RUN useradd hack -s /nethack-launcher +RUN echo 'hack:U6aMy0wojraho' | chpasswd -e +RUN chown -R hack /hack/ + # copy in files COPY config.gcfg / COPY nethack-launcher / diff --git a/deps/run.sh b/deps/run.sh index 1166a6d..253931d 100755 --- a/deps/run.sh +++ b/deps/run.sh @@ -2,3 +2,7 @@ # start redis server redis-server /redis.conf | sed "s/^/[redis] /" + +# start ssh server +mkdir -p /run/sshd/ +exec /usr/sbin/sshd -D diff --git a/nethack-launcher.go b/nethack-launcher.go index b26e198..296302b 100644 --- a/nethack-launcher.go +++ b/nethack-launcher.go @@ -357,7 +357,6 @@ func printRegisterScreen(redisClient *redis.Client) { exec.Command("mkdir", "-p", userPath).Run() // copy in rc file - // TODO make sure rc file exists before copying hackRCLoc := fmt.Sprintf("%s/.nethackrc", config.NethackLauncher.HackDir) hackRCDest := fmt.Sprintf("%s/user/%s/.nethackrc", config.NethackLauncher.HackDir, username) exec.Command("cp", hackRCLoc, hackRCDest).Run()