Last active
April 4, 2024 12:02
-
-
Save elifiner/1a5ed9cb06db1c0fc59a7426e4adc1b1 to your computer and use it in GitHub Desktop.
Create an non-root user on Ubuntu and set up sudo
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 | |
# This script will set up a non-root user on an empty Ubuntu box. | |
# | |
# Login as root and run: | |
# | |
# $ curl https://gist.githubusercontent.com/elifiner/1a5ed9cb06db1c0fc59a7426e4adc1b1/raw | sh - | |
USER=guru | |
adduser --disabled-password --gecos "" $USER | |
adduser $USER sudo | |
mkdir /home/$USER/.ssh | |
cp .ssh/authorized_keys /home/$USER/.ssh | |
chown -R $USER:$USER /home/$USER/.ssh | |
chmod 640 /etc/sudoers | |
echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | |
chmod 440 /etc/sudoers | |
echo "user $USER created." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment