This course has been updated! We now recommend you take the Full Stack for Front-End Engineers, v3 course.

Check out a free preview of the full Full Stack for Front-Ends Part 2 course:
The "Adding SSH keys" Lesson is part of the full, Full Stack for Front-Ends Part 2 course featured in this preview video. Here's what you'd learn in this lesson:

Jem adds an SSH key for the user created earlier, along with covering best SSH practices.

Get Unlimited Access Now

Transcript from the "Adding SSH keys" Lesson

>> Jem Young: Strong authentication, let's add an SSH key. We already did that actually, we did it for the root user, but we need to do that for our current user that we just made. So let's make an SSH directory in our local directory, our home directory. And then we're gonna make a file called authorized keys.

[00:00:17] Then we're just gonna paste our public key into that. This is all in part 1. If you're confused right now, you didn't take part 1. Shame, shame, [LAUGH] no, I'll give you a minute to do that and then I'll do it myself. Why do we have to make .ssh/authorized_keys?

[00:00:35] Well, that's where the SSH domain looks if you're trying to log in. It says I'm gonna look for a public key here, I'm gonna look for public key here. We'd actually rename this to something arbitrary and just change it, but this is a default configuration, and I always say stick with defaults, unless you really know what you're doing.

[00:00:50] But that's just all that's happening, we're making a file, we're putting our public key in there, so that when we wanna handshake with the server it knows where to look.
>> Speaker 2: And this can be the same public key that we have for the user?
>> Jem Young: Yeah,
>> Jem Young: I have seen some people go a bit overboard, they create a server, they create a new SSH key every time, you don't generally have to do that, and it'll just get confusing in the long run.

[00:01:15] You can use one or two. I would encourage you not to use the same SSH keys for say GitHub as your server, as if someone steals one they have access to everything, generally a bad idea. But for servers you can one or two and you'll be okay, no need to go overboard, SSH is pretty strong particle, as we learned in the first course.

>> Jem Young: Okay, I am gonna go ahead and make this. So PWD, print working directory, make sure I'm in the right directory. So I'm gonna mkdir -p, -p says create it if it doesn't already exist, otherwise it will error. I'm gonna say, .ssh. Well, let me use the same syntax I used.

>> Jem Young: Awesome, I'm just gonna cd in there.
>> Jem Young: Say, vi, actually I copied this. I cheated, I cheated, I copied and paste. It's okay, authorize keys. So what do we put in here again? We put our public key. Where do we get that from? So let's just open up a new terminal briefly.

[00:02:27] We won't be back on our home computer that often, but we're just gonna do this, cuz we need to copy our public key. Let me make that extra big. And I'm just gonna cd, same spot, ssh, oops
>> Jem Young: And if you look at the speaker notes, I try to put useful tips in there.

[00:02:56] So I'm gonna use a tool called PB Copy which just takes the output of CAT and then copies it to your clipboard.
>> Jem Young: So pbcopy my public key, notice the .pub, not your private key, just gonna copy that. Plays away, insert, cool. I'm just going to right quit on that.

[00:03:19] All right, so what I did was, I copied my public key into my clipboard, I just pasted in this way. If you remember in part 1, we did it a fancy command line way. It's a bit more complicated. This way is pretty straight forward. It's bullet proof. Command line way is way cooler.

[00:03:35] Impress your friends, impress your grandma, but this way is a bit more simpler. But if you understand the other way [SOUND] do that way too.
>> Jem Young: Okay, now, another warning, make sure you log in with your test user with your SSH key, just to make sure you can.

[00:03:55] You never know. You might have mistyped something. So I'm gonna go ahead and give that a shot. So I'm gonna exit, I'm gonna exit again. So I'm gonna say ssh-i my private key, and I'm gonna say test my user at my IP.
>> Jem Young: And we're logged in.