Skip to content

Instantly share code, notes, and snippets.

@deffjay
Last active October 4, 2020 22:34
Show Gist options
  • Save deffjay/7ad63ab7856e95574a61d9ab527e6baa to your computer and use it in GitHub Desktop.
Save deffjay/7ad63ab7856e95574a61d9ab527e6baa to your computer and use it in GitHub Desktop.
Properly creates a new user for CentOS/RHEL/Fedora/Debian
#!/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