Creating a Deploy Account14:35 with Jay McGavren
Now let's create the actual deployment account. We'll also set it up to use SSH keys, to make logging in more secure.
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
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
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
You need to sign up for Treehouse in order to download course files.Sign up