Created
January 27, 2023 05:24
-
-
Save slackingfred/e7fe2159fe9f1b9ae5ff83e785218d40 to your computer and use it in GitHub Desktop.
Create new user $1 with authorized pubkey file $2
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 | |
# 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