Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Now let's create the actual deployment account. We'll also set it up to use SSH keys, to make logging in more secure.
If the ssh-copy-id
program is present on your local system, it can simplify copying your public key over to the server. Here's a tutorial on using ssh-copy-id
.
If you don't have ssh-copy-id
, run these commands on the server:
sudo mkdir /home/deploy/.ssh
- Fix permissions:
sudo chmod u+rwx /home/deploy/.ssh
sudo chmod go-rwx /home/deploy/.ssh
- Synonym:
sudo chmod 700 /home/deploy/.ssh
You can learn more about the chmod
command in the "Users and Permissions" stage of our Console Foundations course.
Next, we need to get the public key we just generated. This file is on your local computer, not the server. Copy the entire contents of ~/.ssh/id_rsa.pub
. Make sure you're opening the file that ends in .pub
, not the file without an extension. The contents of the file without an extension shouldn't go anywhere except your local computer!
Now that we have the public key, we need to go back to the server and add it to a file. The public keys for our new user should be stored in a file named authorized_keys
within the .ssh
directory we just created.
sudo nano /home/deploy/.ssh/authorized_keys
- Paste the public key into your terminal.
- Save and exit.
Lastly, we need to fix the permissions and ownership of those files:
sudo chmod 400 /home/deploy/.ssh/authorized_keys
sudo chown deploy:deploy /home/deploy -R
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up