Skip to content

Instantly share code, notes, and snippets.

@yanak
Last active March 16, 2018 08:28
Show Gist options
  • Save yanak/e61fd5b6fabb39ac30ec78b14ac1e591 to your computer and use it in GitHub Desktop.
Save yanak/e61fd5b6fabb39ac30ec78b14ac1e591 to your computer and use it in GitHub Desktop.
How to add a user with sudo permission and set up SSH public key

Add a user

$ export USERNAME=<your username> && sudo adduser --home /home/$USERNAME --shell /bin/bash --disabled-password $USERNAME && sudo adduser $USERNAME sudo

Make a directory and file for SSH auth

$ mkdir .ssh && chmod 700 .ssh && cd .ssh && touch authorized_keys && chmod 600 authorized_keys

Add a public key generated by a user to authorized_keys

$ echo '<your public key>' >> authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment