How to Create Authorized Files With Correct Permissions
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" deployCreate the directory and create the the authorized_keys file:
$ mkdir /home/deploy/.ssh
$ touch /home/deploy/.ssh/authorized_keysFrom the client copy the public key:
$ cat ~/.ssh/id_rsa.pub | pbcopy
Back to the server, paste the content into the authorized_keys files:
$ echo ' paste-here ' >> /home/deploy/.ssh/authorized_keysSet the permissions and ownership:
$ chown -R deploy:deploy /home/deploy
$ chmod 700 /home/deploy/.ssh
$ chmod 600 /home/deploy/.ssh/authorized_keys