Skip to content

Instantly share code, notes, and snippets.

@miholeus
Created January 8, 2017 23:05
Show Gist options
  • Save miholeus/6d01cac86b15a7d71c56cbb689f3826c to your computer and use it in GitHub Desktop.
Save miholeus/6d01cac86b15a7d71c56cbb689f3826c to your computer and use it in GitHub Desktop.
docker vagrant
FROM ubuntu:16.04
ENV DEBIAN_FRONTEND noninteractive
# ensure we have the en_US.UTF-8 locale available
RUN locale-gen en_US.UTF-8
# install common dependencies
RUN apt-get update && apt-get install -y \
curl \
lsb-release \
openssh-server \
sudo
# setup the vagrant user
RUN if ! getent passwd vagrant; then useradd -d /home/vagrant -m -s /bin/bash vagrant; fi \
&& echo vagrant:vagrant | chpasswd \
&& echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& mkdir -p /etc/sudoers.d \
&& echo 'vagrant ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/vagrant \
&& chmod 0440 /etc/sudoers.d/vagrant
# add the vagrant insecure public key
RUN mkdir -p /home/vagrant/.ssh \
&& chmod 0700 /home/vagrant/.ssh \
&& wget --no-check-certificate \
https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \
-O /home/vagrant/.ssh/authorized_keys \
&& chmod 0600 /home/vagrant/.ssh/authorized_keys \
&& chown -R vagrant /home/vagrant/.ssh
# don't clean packages, we might be using vagrant-cachier
RUN rm /etc/apt/apt.conf.d/docker-clean
# run sshd in the foreground
CMD /usr/sbin/sshd -D \
-o UseDNS=no\
-o UsePAM=no\
-o PasswordAuthentication=yes\
-o UsePrivilegeSeparation=no\
-o PidFile=/tmp/sshd.pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment