Skip to content

Instantly share code, notes, and snippets.

@smashnet
Created February 8, 2019 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smashnet/48873e70db97c864295f5fb398b63472 to your computer and use it in GitHub Desktop.
Save smashnet/48873e70db97c864295f5fb398b63472 to your computer and use it in GitHub Desktop.
Add new no-shell-user and add self to group
#!/bin/bash
if [ -z "$1" ]; then
echo "Please provide a name for the new user!"
exit 1
fi
echo "Creating user and group -$1- and adding you ($(whoami)) to that group."
echo -n "Sure ye wanna do this? (y/N) -> "
read answer
if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then
echo "Doing it so!"
sudo useradd -r -s /sbin/nologin $1
sudo usermod -a -G $1 $(whoami)
echo "Done!"
echo $(id $1)
else
echo "Ok, did not do anything... bye!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment