Created
October 12, 2021 16:30
-
-
Save PackeTsar/b9a857f694f82898f260b6a9f7ef5f63 to your computer and use it in GitHub Desktop.
Use a different user on each login
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
# /root/newuser.sh | |
# | |
# Create and use a new user every time you log in. | |
# | |
# Setup: | |
# ~$ nano newuser.sh | |
# *paste contents of this file and save* | |
# ~$ chmod +x newuser.sh | |
# ~$ echo "bash newuser.sh" >> ~/.profile | |
# Create a new random username | |
newuser=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 5 | head -n 1) | |
# Add the new user | |
sudo adduser --quiet --disabled-password --shell /bin/bash --gecos "User" $newuser | |
# Set the user password | |
echo "$newuser:supersupersecret" | chpasswd | |
# Move to the users home dir | |
cd /home/$newuser | |
# Switch to the new user | |
su $newuser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment