Make suitable for use as a docker-hosted shell
This commit is contained in:
parent
8d414f80cc
commit
30ae4064b7
39
Dockerfile
39
Dockerfile
@ -1,35 +1,40 @@
|
||||
FROM ubuntu:14.04
|
||||
FROM ubuntu:trusty
|
||||
MAINTAINER Dave P
|
||||
|
||||
# docker run -p 8822:22 -d --name="basessh_test" basessh /start
|
||||
# docker run -d -p 8822:22 -v /Users/dave/Documents/Code/docker_basessh/test:/etc/ssh/keys --name="basessh_test" shel
|
||||
|
||||
# Create admin
|
||||
RUN useradd --create-home --groups sudo admin ; \
|
||||
echo "admin:admin" | chpasswd ; \
|
||||
locale-gen en
|
||||
RUN useradd --create-home --groups sudo admin && \
|
||||
echo "admin:admin" | chpasswd && \
|
||||
locale-gen en && \
|
||||
mkdir /var/run/sshd && \
|
||||
apt-get update -y && \
|
||||
apt-get -y install openssh-server rsync screen tmux vim supervisor htop && \
|
||||
rm -rf /etc/ssh/*_key* && \
|
||||
mkdir /etc/ssh/keys && \
|
||||
sed -i -E 's/HostKey \/etc\/ssh\//HostKey \/etc\/ssh\/keys\//' /etc/ssh/sshd_config && \
|
||||
su -c "mkdir ~/.ssh /home/admin/persist" admin
|
||||
|
||||
# Install base software
|
||||
RUN mkdir /var/run/sshd ; \
|
||||
apt-get update -y ; \
|
||||
apt-get -y install openssh-server rsync screen tmux vim supervisor htop ; \
|
||||
rm -rf /etc/ssh/*
|
||||
|
||||
# SSH cert
|
||||
RUN su -c "mkdir ~/.ssh" admin
|
||||
COPY authorized_keys /home/admin/.ssh/authorized_keys
|
||||
RUN chown -R admin /home/admin/.ssh ; chgrp -R admin /home/admin/.ssh ; chmod -R 700 /home/admin/.ssh
|
||||
|
||||
RUN chown -R admin /home/admin/.ssh && \
|
||||
chgrp -R admin /home/admin/.ssh && \
|
||||
chmod -R 700 /home/admin/.ssh
|
||||
|
||||
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
|
||||
COPY sshd.conf /etc/supervisor/conf.d/sshd.conf
|
||||
COPY cron.conf /etc/supervisor/conf.d/cron.conf
|
||||
|
||||
COPY start /start
|
||||
RUN chmod +x /start ; mkdir /start.d
|
||||
COPY regenerate-ssh /start.d/regenerate-ssh
|
||||
RUN chmod +x /start.d/regenerate-ssh
|
||||
COPY user-rc /start.d/user-rc
|
||||
|
||||
RUN chmod +x /start /start.d/regenerate-ssh /start.d/user-rc
|
||||
|
||||
# Expose ssh
|
||||
EXPOSE 22
|
||||
|
||||
VOLUME /home/admin/persist
|
||||
|
||||
# Set boot command
|
||||
CMD /start
|
||||
ENTRYPOINT /start
|
||||
|
@ -1,3 +1,3 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDF/g6WkXW1GeC7jW4nM1DCeFOQNp6Vu6T1AY7yYI+hBe77fMQl0MzeEz5TfoFRAIlDeC0guXV+mY8UcjZzsIZWnLn2Kg4PdxHtGG8JUlPxBe0/+hmqLgCdd1KusqKHaFgI6fhwMOaWCGslHXZPzS0culVk0GyClXQRTwD58R9FuhY9qScnPpg+Dhwjn4G2FzgX3N23ucvLICE39NOGqEUNpcVhCqC1BULfVFdpDSN6pIepIUIq3fdEAVsjsaCowefghdETI9v6TcbcHClWO8w0Mjuk+BxHbm2Nli4S4K1J7keg4NraYO9+FMnH7PUCqv0Ixb/RxR+186Ump5ZFDQTp dave@daves-mbp.americas.hpqcorp.net
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCel0EJ4Apj/k3abQ63nDP7IyUrTWQpkN9Feg2J3azBTKhmKw1lUXXxm6Nm9Ek+SmuUTM4+nPnOv76e8HNMOsUniKVhdjw937KfxHxEoEJ/barLOsOxcmeNU5Nl0Q7TNs7UhVLw+4tSXlQKXZOUeNPuT718ri8zB9da4lV5iQZzYSH1nYzpvmrO5Gb1ImjaQPncNAM/SHbRGkspP2oxFQS7nzhDltxpDMZHbH5Q8xcuFlDMNQBcy1D1xWpXm/PhS8q/kchW0tun63M1emM8zVrNtTTlNTMxXDNeJx1oDxvcCOq8Q7QTsCWkb6f3X214uwskm6KGkXJmDDGGTvQUawcX ubuntu@shell1
|
||||
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC5HRHqx5cA3n/G4JVfdncC0QEEpC6+kQ8tpe1LYEcUbjLcyRzuilG7/8YAnlGNPs5Ad9WslrNfHsAxVSy7mwlzVgXpcCqAX9FruAkb48f9cs+FKYul4u8Ctj2cL0XE3Hb5Ix4jXW1h54MVUxmqoE6TciMttFTr3+64Wo9UmFSs5A6AK+Hwb74jfAi2nNSR09oDaucp9r4vQzXNL8Jz/EVusOGSnVtWnkuNrHZT/nYoCqZm+Th3aK7T3H/g+8kOcvckIyp1lj+EJ+X9a7u9JE3LGxdGpbwIYymAY6ZmAkfL0i+Idowtg73fIu9jroLaJbc2AdRqNY2QZRw9iotwrCcB dave@minicaraxes.local
|
||||
|
15
regenerate-ssh
Normal file → Executable file
15
regenerate-ssh
Normal file → Executable file
@ -1,10 +1,15 @@
|
||||
#! /bin/bash
|
||||
|
||||
# If sshd has no config, generate new keys + config
|
||||
if [ ! -f /etc/ssh/sshd_config ]; then
|
||||
# Regenerate ssh key per container
|
||||
dpkg-reconfigure openssh-server
|
||||
#!/bin/sh
|
||||
|
||||
# Regenerate ssh key per container
|
||||
|
||||
if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then
|
||||
# Regen keys
|
||||
ssh-keygen -A
|
||||
|
||||
# Move keys to keys dir
|
||||
mv /etc/ssh/ssh_host_* /etc/ssh/keys/
|
||||
fi
|
||||
|
||||
# This only runs once, so remove this startup script
|
||||
rm /start.d/regenerate-ssh
|
||||
|
Loading…
Reference in New Issue
Block a user