Skip to content

Instantly share code, notes, and snippets.

@marcopeg
Last active October 5, 2016 13:01
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 marcopeg/3e8a5045459816aef64378d7ed2421e3 to your computer and use it in GitHub Desktop.
Save marcopeg/3e8a5045459816aef64378d7ed2421e3 to your computer and use it in GitHub Desktop.
Setup Docker on Ubuntu Server
#/bin/bash
#
# wget -O - https://gist.github.com/marcopeg/3e8a5045459816aef64378d7ed2421e3/raw | bash -s my_custom_user
#
PASS=$(date | sha256sum | base64 | head -c 32)
USER=${1:-duser}
# Create Docker User
useradd -d /home/$USER -m $USER
usermod -aG sudo $USER
echo "$USER:$PASS" | chpasswd
# Install Docker
apt-get update \
&& apt-get install curl -y \
&& wget -O - https://bit.ly/docker-install | bash \
&& usermod -aG docker $USER
# Update Config Files
sed -i "s/home\/$USER:/home\/$USER:\/bin\/bash/g" /etc/passwd
sed -i "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config
# Restart SSH
service ssh restart
echo "##############################"
echo "# User: $USER"
echo "# Pass: $PASS"
echo "#"
echo "# Now you should logout from"
echo "# and login as \"$USER\""
echo "##############################"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment