Commit 2eebb901 authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Added base and SSh containers.

parent df22203d
Loading
Loading
Loading
Loading

SSH/Dockerfile

0 → 100644
+28 −0
Original line number Original line Diff line number Diff line
FROM base
MAINTAINER Stefano Alberto Russo <stefano.russo@inaf.it>

# Switch to root
USER root

# Install OpenSSH
RUN apt-get install openssh-server  -y

# Set a fixed password for metauser (will be changed in the entypoint)
RUN echo "metauser:metapass" | chpasswd

# Set entrypoint command
COPY files/entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
ENV DEFAULT_ENTRYPOINT_COMMAND="/entrypoint.sh"

# Fix home permissions
RUN chmod 777 /home

# Set user (mainly for Singularity)
USER metauser

# Set container name
ENV CONTAINER_NAME='SSH'


SSH/build.sh

0 → 100755
+3 −0
Original line number Original line Diff line number Diff line
#!/bin/bash

docker build  . -t ssh
+39 −0
Original line number Original line Diff line number Diff line
#/bin/bash

# Set port
if [ "x$BASE_PORT" == "x" ]; then
    BASE_PORT=22
fi

# Set password
if [ "x$AUTH_PASS" != "x" ]; then
    echo "[INFO] Setting linux password" # In the Dockerflie remove the -e
    echo -e "metapass\n$AUTH_PASS\n$AUTH_PASS" | passwd
fi

# Prepare conf
mkdir ${HOME}/custom_ssh
ssh-keygen -f ${HOME}/custom_ssh/ssh_host_rsa_key -N '' -t rsa
ssh-keygen -f ${HOME}/custom_ssh/ssh_host_dsa_key -N '' -t dsa

cat << EOF > ${HOME}/custom_ssh/sshd_config
Port $BASE_PORT
HostKey ${HOME}/custom_ssh/ssh_host_rsa_key
HostKey ${HOME}/custom_ssh/ssh_host_dsa_key
AuthorizedKeysFile  .ssh/authorized_keys
ChallengeResponseAuthentication no
UsePAM yes
Subsystem   sftp    /usr/lib/ssh/sftp-server
PidFile ${HOME}/custom_ssh/sshd.pid
EOF

# Run
echo "[INFO] Now running SSH server on port $BASE_PORT and listening."
/usr/sbin/sshd -D -f ${HOME}/custom_ssh/sshd_config
EXIT_CODE=$?
echo "Exit code: $EXIT_CODE"
if [[ "x$EXIT_CODE" != "x0" ]] && [[ "x$EXIT_CODE" != "x130" ]] ; then
    echo "This exit code is an error, exiting." 
    exit $?
fi
echo ""
 No newline at end of file

SSH/run.sh

0 → 100755
+2 −0
Original line number Original line Diff line number Diff line
#!/bin/bash
docker run -v$PWD/:/data -p2222:2222 -eAUTH_PASS='testpass' -eBASE_PORT=2222 -it ssh

base/Dockerfile

0 → 100644
+57 −0
Original line number Original line Diff line number Diff line
FROM ubuntu:18.04
MAINTAINER Stefano Alberto Russo <stefano.russo@inaf.it>

#----------------------
# Basics
#----------------------

# Set non-interactive
ENV DEBIAN_FRONTEND noninteractive

# Update first of all
RUN apt-get update

# Utilities
RUN apt-get install -y nano telnet unzip wget supervisor build-essential python-dev git-core openjdk-8-jre


#------------------------
# "Meta" user
#------------------------

# Add group. We chose GID 65527 to try avoiding conflicts.
RUN groupadd -g 65527 metauser

# Add user. We chose UID 65527 to try avoiding conflicts.
RUN useradd metauser -d /home/metauser -u 65527 -g 65527 -m -s /bin/bash

# Add metuaser user to sudoers
RUN adduser metauser sudo

# Install suodo
RUN apt-get install sudo -y

# No pass sudo (for everyone, actually)
COPY files/sudoers /etc/sudoers

# Prepare for user-space logs
RUN mkdir /home/metauser/.logs && chown metauser:metauser /home/metauser/.logs

# Rename metauser home folder as a "vanilla" home folder
RUN mv /home/metauser /metauser_home_vanilla

# Set container name
ENV CONTAINER_NAME='base'

# Entrypoint
COPY files/base_entrypoint.sh /
RUN chmod 755 /base_entrypoint.sh
ENTRYPOINT ["/base_entrypoint.sh"]
ENV DEFAULT_ENTRYPOINT_COMMAND="/bin/bash"

# Allow to move the /home_vanilla folder in /home
RUN chmod 777 /home

# Set user
USER metauser
Loading