Skip to content

Instantly share code, notes, and snippets.

@chloerei
Created March 5, 2014 07:07
Show Gist options
  • Save chloerei/9362532 to your computer and use it in GitHub Desktop.
Save chloerei/9362532 to your computer and use it in GitHub Desktop.
Create a deploy user with githu keys when setup vps
#!/bin/bash
USER=deploy
KEYS_PATH=https://github.com/chloerei.keys
useradd -s /bin/bash -m deploy
passwd $USER
adduser $USER sudo
mkdir /home/$USER/.ssh
wget $KEYS_PATH -O /home/$USER/.ssh/authorized_keys
chmod 700 /home/$USER/.ssh
chmod 600 /home/$USER/.ssh/authorized_keys
chown -R $USER:$USER /home/$USER/.ssh/
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config
service ssh restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment