In this post we will demonstrate how to create authorized files with correct permissions in Linux.

First create the deploy user and in my case add it to the docker group:

$ useradd -s /bin/bash -m -G docker -c "docker deploys" deploy

Create the directory and create the the authorized_keys file:

$ mkdir /home/deploy/.ssh
$ touch /home/deploy/.ssh/authorized_keys

From the client copy the public key:

$ cat ~/.ssh/ | pbcopy

Back to the server, paste the content into the authorized_keys files:

$ echo ' paste-here ' >> /home/deploy/.ssh/authorized_keys

Set the permissions and ownership:

$ chown -R deploy:deploy /home/deploy
$ chmod 700 /home/deploy/.ssh
$ chmod 600 /home/deploy/.ssh/authorized_keys