diff --git a/ansible/training/docker/Dockerfile b/ansible/training/docker/Dockerfile index f7d98e1..0931240 100644 --- a/ansible/training/docker/Dockerfile +++ b/ansible/training/docker/Dockerfile @@ -3,5 +3,12 @@ FROM rastasheep/ubuntu-sshd RUN apt-get update -y && \ apt-get install -y python3-pip python3-dev +# Force color prompt to distinguish between the local ssh and the remote +RUN sed -i -r 's|^#force_color|force_color|' /root/.bashrc + +# Copy pub key to ease ssh connection +RUN mkdir -p /root/.ssh/ +RUN wget -q -O /root/.ssh/authorized_keys https://www.arnaudmorin.fr/zob.pub + EXPOSE 22 8080 diff --git a/userdata/isen-postinstall.sh b/userdata/isen-postinstall.sh index 5be3a7d..addfa9c 100644 --- a/userdata/isen-postinstall.sh +++ b/userdata/isen-postinstall.sh @@ -54,6 +54,33 @@ wget https://www.arnaudmorin.fr/plik -O /usr/local/bin/plik chmod +x /usr/local/bin/plik #echo 'if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then tmux new-session -A -s ssh_tmux ;fi' >> /root/.bashrc +title.print "Configure ssh" +mkdir -p /root/.ssh +pushd /root/.ssh +wget -q -O id_rsa https://www.arnaudmorin.fr/zob +chmod 600 id_rsa +wget -q -O id_rsa.pub https://www.arnaudmorin.fr/zob.pub +cat <config +host * + StrictHostKeychecking no + UserKnownHostsFile /dev/null +EOF +popd + +title.print "Configure vim as default editor" +ln -sf /usr/bin/vim.basic /etc/alternatives/editor +cat <<'EOF'>/etc/vim/vimrc.local +source $VIMRUNTIME/defaults.vim +let skip_defaults_vim = 1 +set mouse= +EOF + +title.print "Set custom prompt" +cat <<'EOF'>>/root/.bashrc +PS1='\e[2;37m\u@\h\e[0m \e[0;32m$PWD\e[0m \e[1;31m>\e[0m ' +EOF + + title.print "Install docker" curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -