Last active
October 5, 2016 13:01
-
-
Save marcopeg/3e8a5045459816aef64378d7ed2421e3 to your computer and use it in GitHub Desktop.
Setup Docker on Ubuntu Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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