Last active
October 4, 2020 22:34
-
-
Save deffjay/7ad63ab7856e95574a61d9ab527e6baa to your computer and use it in GitHub Desktop.
Properly creates a new user for CentOS/RHEL/Fedora/Debian
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 | |
# Create a new user named morpheus | |
useradd -m -s /bin/bash morpheus | |
# Add users to sudo or wheel group | |
usermod -aG sudo morpheus #Debian/Ubuntu | |
usermod -aG wheel morpheus #CentOS/RHEL | |
# Create Home Directory + .ssh Directory | |
mkdir -p /home/morpheus/.ssh | |
# Create Authorized Keys File | |
touch /home/morpheus/.ssh/authorized_keys | |
# Set the permissions correctly for the ssh folders | |
chmod 700 /home/morpheus/.ssh | |
chmod 644 /home/morpheus/.ssh/authorized_keys | |
# Set the users password | |
passwd morpheus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment