Skip to content

Instantly share code, notes, and snippets.

@csabatini
Created January 2, 2017 20:56
Show Gist options
  • Select an option

  • Save csabatini/d58bbb76aafe9e77d2df6330956f0434 to your computer and use it in GitHub Desktop.

Select an option

Save csabatini/d58bbb76aafe9e77d2df6330956f0434 to your computer and use it in GitHub Desktop.
#!/bin/bash
function add_user_and_key() {
USER=$1
KEY=$2
useradd $USER
mkdir -p /home/${USER}/.ssh/
cp {~/.bashrc,~/.bash_profile} /home/${USER}
sh -c "echo ${KEY} >> /home/${USER}/.ssh/authorized_keys"
chown ${USER}:${USER} -R /home/${USER}
chmod -R 700 /home/${USER}
chmod 640 /home/${USER}/.ssh/authorized_keys
}
add_user_and_key csabatini ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment