Skip to content

Instantly share code, notes, and snippets.

@slashtechno
Last active August 21, 2023 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slashtechno/cc7cd208a8c04716968f37b05298794d to your computer and use it in GitHub Desktop.
Save slashtechno/cc7cd208a8c04716968f37b05298794d to your computer and use it in GitHub Desktop.
Dockerfile to create a Ubuntu container with zsh and shellinabox
# docker build --file Dockerfile-devenv.txt -t devenv .
# docker run -it --name devenv -p 4200:4200 -d devenv zsh
FROM ubuntu:latest
ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
WORKDIR /home/$USERNAME
USER $USERNAME
RUN sudo apt-get update
RUN sudo apt-get upgrade -y
RUN sudo apt-get install zsh git curl bash vim nano openssh-server shellinabox -y
RUN sudo chsh -s $(which zsh) $USERNAME
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
RUN git clone https://github.com/zsh-users/zsh-autosuggestions.git /home/$USERNAME/.oh-my-zsh/custom/plugins/zsh-autosuggestions
RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /home/$USERNAME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
RUN curl https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash
RUN echo export ZSH=\"\$HOME/.oh-my-zsh\" > /home/$USERNAME/.zshrc
RUN echo ZSH_THEME=\"robbyrussell\" >> /home/$USERNAME/.zshrc
RUN echo plugins=\(git zsh-autosuggestions zsh-syntax-highlighting\) >> /home/$USERNAME/.zshrc
RUN echo source \$ZSH/oh-my-zsh.sh >> /home/$USERNAME/.zshrc
#RUN echo service shellinabox start >> /home/$USERNAME/.zshrc
USER root
#RUN echo -e "new_password\nnew_password" | (passwd $USERNAME)
RUN echo "$USERNAME:password" | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
RUN sed -i 's/SHELLINABOX_ARGS="--no-beep"/SHELLINABOX_ARGS="--no-beep --disable-ssl"/g' /etc/default/shellinabox
USER $USERNAME
EXPOSE 4200
# CMD ["/usr/bin/shellinaboxd", "--port", "4200", "--no-beep", "--disable-ssl"]
CMD ["zsh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment