Locked lesson.
About this lesson
There is no description for this lesson.
Exercise files
Download this lesson’s related exercise files.
Generate SSH Key.docx57.3 KB Generate SSH Key - Solution.docx
59.8 KB
Quick reference
Generate SSH Key
In this lesson we'll genearate an SSH Key.
When to Use
You should do this one time for this project. After the key has been created, we can use it whenever we want in the future.
Instructions
From the Git Bash terminal, make sure you're in your default directory. Create an SSH directory with this command:
mkdir .ssh
Next move into that directory:
cd .ssh
Next generate your ssh key with this command:
ssh-keygen.exe
That's it!
Login to download
- 00:04 We need to do one more thing before we install Ruby on Rails which is generate
- 00:08 an SSH key.
- 00:09 And an SSH key is a security feature,
- 00:11 it allows us to connect to other web sites securely.
- 00:15 And we're going to use that to push our code up to GitHub later on for
- 00:18 version control.
- 00:19 Ruby on Rails also requires an SSH key, I believe,
- 00:22 just to be handy on your computer so we'll go ahead and do that now.
- 00:25 So I've opened up Git Bash, I just went to my Windows Start menu, typed in Git and
- 00:30 the Git Bash icon popped up, went ahead and clicked it and this is the screen.
- 00:34 So your's will look a little different up here.
- 00:37 Mine says flatplanet-PC because that's the name of my computer.
- 00:40 I don't think the world is flat I just find it hilarious that some people do so
- 00:43 I named my computer that.
- 00:45 Whatever your logged in user name is or computer name is,
- 00:48 that's what you'll see there.
- 00:50 And if we actually type in pwd,
- 00:52 we can see right now we're in the C drive Users/flatplanet.
- 00:56 This is just the default directory and that's where we want to be.
- 01:00 Of course, your's will say something besides flatplanet but you get the idea.
- 01:03 So the first thing we need to do is create a directory in order to hold our SSH key.
- 01:08 So I'm going to use the command mkdir, it stands for make directory.
- 01:12 And then I want to type in .ssh, and this will create a directory called .ssh.
- 01:18 And a directory with a period in front of it means that the directory is hidden,
- 01:21 you won't be able to see it.
- 01:23 And since this is a secure SSH key thing, that's what we want.
- 01:27 We want this directory to be hidden.
- 01:28 So, we can click that.
- 01:29 Now, we need to move into that directory to create our key.
- 01:33 So, we're going to change directory, use the cd command and then just type .ssh.
- 01:38 And you can see right here it shows that we're in .ssh.
- 01:42 Or we can type in pwd and it'll confirm we are in fact in the .ssh directory.
- 01:49 So now, I'm going to clear the screen, just type clear.
- 01:52 And in order to generate a SSH key, it used to be really hard,
- 01:55 you used to have to download software to do it and it was a huge hassle.
- 01:59 These days there's a key generator built into this Git Bash terminal,
- 02:02 which was one of the cool things about it.
- 02:04 One of the reasons why we like to use it.
- 02:06 So to create an SSH key, you just type in ssh-keygen.exe.
- 02:14 And it runs this little thing and it asks where we would like to save it,
- 02:17 we just want to save it in this directory that we're in so I can just hit Enter.
- 02:21 Now it's asking for a passphrase or a password.
- 02:24 Now, if you'd like to enter a password here, go ahead.
- 02:28 If you type on your keyboard a password, it won't show up on the screen,
- 02:31 that's a security feature but don't worry, it's actually typing it in.
- 02:35 But personally I don't ever put a password here
- 02:38 because this is already a security feature.
- 02:41 Adding a password on top of it seems like overkill to me.
- 02:44 And you just don't really need to, there's no hackers that are going to
- 02:47 compromise your system if you don't have a password for this thing.
- 02:50 And later on when we push our Ruby on Rails code up to GitHub it'll ask for
- 02:54 a password for your SSH key if you created it now.
- 02:58 So if you type a password now, remember that password, you have to know that
- 03:02 forever, but me personally, I'm not going to put a password in.
- 03:06 I just don't think you need to, so I'm going to go ahead and Enter.
- 03:09 It says enter the same passphrase again.
- 03:11 I didn't type one, so I can hit Enter again.
- 03:13 If you did type on, you'll have to enter it again.
- 03:15 And boom, it's created our SSH key.
- 03:17 So now, if we clear the screen, and type in ls to list the stuff that's in
- 03:22 this directory, we see there's these two files, id_rsa and id_rsa.pub.
- 03:30 This is the private key and this is the public key.
- 03:32 It's the public key that we're interested in.
- 03:34 And in fact we can take a look at it by typing cat to catalog it out onto
- 03:39 the screen.
- 03:40 And then id_rsa.pub and this is our SSH key.
- 03:46 So it's just a bunch of gobbledygook.
- 03:48 It doesn't mean anything to us.
- 03:49 But it's kind of cool that we've created it now.
- 03:51 Later on when we push our code up to GitHub,
- 03:54 we'll have to copy this SSH key and paste it into GitHub.
- 03:58 So to do that you just come back to this directory, type in cat id_rsa.pub.
- 04:04 This thing will pop up.
- 04:05 Highlight it all, right-click it and copy it.
- 04:08 And you can just paste it into GitHub.
- 04:10 We'll probably talk about it more later on.
- 04:12 But this is where it will be if you ever need it.
- 04:15 And so now, we're good to go.
- 04:17 We have all the tools and all the things that we need to for Ruby on Rails to
- 04:20 download and install, so in the next video we'll go ahead and do that.
Lesson notes are only available for subscribers.