Skip to content

Instantly share code, notes, and snippets.

@huehnerhose
Last active November 9, 2020 17:48
Show Gist options
  • Save huehnerhose/d1bc4ec8cd5e478eb9dbb2d3365afc23 to your computer and use it in GitHub Desktop.
Save huehnerhose/d1bc4ec8cd5e478eb9dbb2d3365afc23 to your computer and use it in GitHub Desktop.
#!/bin/sh
echo Username
read username
echo GroupAdds - comma separated group list
read groups
# be sure password database to be in sync
pwd_mkdb -p /etc/master.passwd
pw useradd -n $username -s /usr/local/bin/zsh -G $groups -m -w random
mkdir /home/$username/.ssh
echo PublicKey
read pubkey
echo $pubkey > /home/$username/.ssh/authorized_keys
chmod 700 /home/$username/.ssh
chmod 600 /home/$username/.ssh/authorized_keys
chmod -x /home/$username/.ssh/authorized_keys
chown -R $username:$username /home/$username/.ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment