From 10d7318e566998b36935fe63552edb2edcaee5d6 Mon Sep 17 00:00:00 2001 From: Clemens Elflein Date: Tue, 23 Jul 2024 15:53:33 +0200 Subject: [PATCH] Added SSH to devenv on port 2222 (#124) --- devenv/Dockerfile | 16 ++++++++++++++-- devenv/docker-compose.yaml | 4 +--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/devenv/Dockerfile b/devenv/Dockerfile index 6d737e39..c2fd1b87 100644 --- a/devenv/Dockerfile +++ b/devenv/Dockerfile @@ -7,9 +7,20 @@ ARG MY_USER RUN groupadd -g ${MY_GID} -o ${MY_USER} # Create a new user, assign it to the group, and set its shell to bash -RUN useradd -m -u ${MY_UID} -g ${MY_GID} -o -s /bin/bash ${MY_USER} +RUN useradd -m -u ${MY_UID} -g ${MY_GID} -o -s /bin/bash ${MY_USER} && yes ${MY_USER} | passwd ${MY_USER} -RUN apt-get update && apt-get install -y zsh git +RUN apt-get update && apt-get install -y zsh git sudo ssh gdb rsync +RUN echo "$MY_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +RUN ( \ + echo 'LogLevel DEBUG2'; \ + echo 'PermitRootLogin yes'; \ + echo 'PasswordAuthentication yes'; \ + echo 'ListenAddress 0.0.0.0:2222'; \ + echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \ + ) > /etc/ssh/sshd_clion \ + && mkdir /run/sshd +RUN bash -c "ssh-keygen -A" # Update rosdep package manager for ROS RUN rosdep update --rosdistro $ROS_DISTRO @@ -36,3 +47,4 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* +CMD ["sudo", "/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_clion"] diff --git a/devenv/docker-compose.yaml b/devenv/docker-compose.yaml index f5177595..abe63ec9 100644 --- a/devenv/docker-compose.yaml +++ b/devenv/docker-compose.yaml @@ -7,8 +7,6 @@ services: - MY_UID=${MY_UID:-1000} - MY_GID=${MY_GID:-1000} - MY_USER=${MY_USER:-dev} - # this will block forever and keep the container running - command: tail -F /dev/null environment: - DISPLAY=${DISPLAY} - QT_X11_NO_MITSHM=1 @@ -17,4 +15,4 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix:rw - ../:/workspace:rw user: "${MY_UID:-1000}:${MY_GID:-1000}" - + network_mode: "host"