Skip to content

Instantly share code, notes, and snippets.

@slackingfred
Created January 27, 2023 05:24
Show Gist options
  • Save slackingfred/e7fe2159fe9f1b9ae5ff83e785218d40 to your computer and use it in GitHub Desktop.
Save slackingfred/e7fe2159fe9f1b9ae5ff83e785218d40 to your computer and use it in GitHub Desktop.
Create new user $1 with authorized pubkey file $2
#!/bin/bash
# 2014-02-26 custom script for adding user on servers.
# Ubuntu servers were not shipped with `adduser` back then.
# For newer versions of Ubuntu, use `adduser` instead.
sudo su
useradd $1
passwd $1
cd /home
mkdir $1
cd $1
cp ~/.bashrc .
mkdir .ssh
chmod 700 .ssh
mv $2 .ssh/authorized_keys
cd ..
chown -R $1:$1 $1
vi /etc/passwd # manually change default shell to bash
vi /etc/group # manually add to `sudo` group (optional)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment