Skip to content

Instantly share code, notes, and snippets.

@federicojd
Forked from learncodeacademy/deployUser.md
Last active March 9, 2025 17:12
Show Gist options
  • Save federicojd/636a01659ae716945cda to your computer and use it in GitHub Desktop.
Save federicojd/636a01659ae716945cda to your computer and use it in GitHub Desktop.
Adding a deploy user in Linux

(wherever it says url.com, use your server's domain or IP)

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

Now login as that user

Create a directory called .ssh on the remote server and log out

mkdir .ssh
exit

Push your ssh key to the authorized_keys file on the remote server

scp ~/.ssh/id_rsa.pub [email protected]:~/.ssh/authorized_keys

Make sure that the permissions are correct

chmod go-w /home/deploy
chmod 700 /home/deploy/.ssh
chmod 600 /home/deploy/.ssh/authorized_keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment