Created
September 19, 2018 01:00
-
-
Save kaashmonee/ac7ddd722c1010f2b71e8c292a4f158f to your computer and use it in GitHub Desktop.
Creates a user on a linux system using the first command line arg, sets a temporary password, and adds them to the root and Docker groups.
This file contains 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 | |
# Ensure that script is being run as root. | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root!" | |
exit 1 | |
fi | |
# Getting username from cmd line | |
username=$1 | |
# Creating a new user from username | |
echo "Creating a new user with name: $username" | |
echo "Type the following as the temporary password: <TEMP_PASS_HERE>" | |
adduser $username | |
# force user to change their password upon login | |
chage -d 0 $username | |
# Adding user to sudo group | |
usermod -aG sudo $username | |
# Adding user to dockergroup | |
usermod -aG docker $username | |
echo "Please ensure that $username is in the appropriate groups:" | |
groups $username |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment