In the last video you initialized a new get repository for the web server project.
You also added a couple of commits and now we can take those comments and send them off to these third
party services we want to use.
Get hub and Heroku so they can access our latest code.
That's how we get hub.
We'll be able to host our project and how Heroku we'll be able to deploy the latest version of our application.
Now the question is how do we transfer the code between our machine and the other third party services
servers in a secure way.
And the answer is to use S S H SS H stands for secure shell and it gives us a means of securely communicating
with another machine.
And in this video we're going to set up what's known as an SS H key pair.
This is a set of two files which we'll be using to facilitate this secure communication.
Now to actually generate these files all we need to do is run some commands from the terminal.
Then in the next two videos we'll actually set things up with both get hub and Heroku.
Now if you're on mac or on Linux you can stick with your standard terminal.
If you are on Windows you need to use the get bash program.
So remember when we first installed get I said that if you're on Windows as you move through the installation
process you want to check that box that says install get bash.
This is when we're actually going to use that program.
The commands we're gonna run are not available to you from these standard windows command prompt.
You need to use get bash to access them.
Now if you didn't install get bash when you installed it you can always grab the installer again rerun
it adding the option to install get bash then you can continue on with the lesson.
So once again Windows users crack open get bash Mac and Linux users you can stick with your terminal
right inside of Visual Studio code.
Now the first thing we're going to do is see if we already have SS keys on our machine.
It's possible you have them from another project you were working on the command we're going to run
is L S now less allows us to list out the contents of a directory and this is going to allow us to check
for existing keys so that's going to list out all of the files and folders inside of a given directory.
We're gonna be running this with the a flag the a flag makes sure that even hidden files and folders
show up these would be ones that start with a dot also known as DOT files and we'll also use the L flag.
This is just gonna make the format a bit easier for us to read.
It's gonna list everything out top to bottom instead of trying to use columns where we have things side
to side and the last thing we need to provide is the path to the folder of which we are trying to print
its contents.
Now for us that is going to be the following It is Tilde forward slash dot SS H.
So Tilde is a shortcut for your user directory then we're looking for the DOT SSA folder.
Now there's a chance you don't even have this folder in which case the command is going to fail.
That is okay.
It's perfectly fine if you get an error something along the lines of directory not found in this case
when I run it.
The folder does indeed exist but there's nothing inside of it.
I have dot which represents the directory and I have dot dot which represents the parent directory.
There are no files inside of the dot SSA folder which means that I don't have any SSA age kids.
Now if you have a file called I d underscore RSA and another called I d underscore RSA dot Pub.
That means you do already have a set of SSA keys and you could choose to use those instead of creating
new ones.
There is no need to create new ones if you already have some in place.
Now if you are seeing what I'm seeing and you have no files or you don't even have the folder it's time
to run a couple other commands to create some SSA keys that we can use the command we're gonna use as
SSA H hyphen key gen which is going to allow us to generate this SSA H key pair.
The first argument of three we'll be providing is t which stands for type.
There are various protocols we can use we'll be using the very popular and very secure RSA protocol.
Now RSA doesn't stand for anything in particular related to software development.
It's actually just the last name initial for the three creators of the algorithm.
So after RSA we're going to specify B for bits we want to specify how many bits for this key we want
enough to be secure.
The most common value is forty ninety six so four thousand and ninety six bits for the key last up hyphen
capital C make sure it's capital and not lower case.
This is where we can provide a comment for the key what you can think of as a label and it's common
to just use your email address inside of here and that's what I'm gonna do right here.
Perfect.
Now that we have this in place we can go ahead and hit enter to run the command.
This is gonna bring us through a little wizard which is going to ask us a few more questions enter a
file in which to save the key and by default you can see it storing it in that dot SSA directory inside
of my user profiles folder and the file name is I d underscore RSA.
I do want to use that default so I'll just hit enter to accept the default value shown in parentheses.
Next up enter a passphrase.
We're not gonna provide a passphrase so we can hit enter to use the default pass rage wishes no passphrase
after that we hit enter again to accept our passphrase and then right here the key has been created.
Now what we're gonna do is run that same Ellis command so I'm gonna use the up arrow key twice hit enter
run it and now I can see I have two files I have I.D. RSA an I.D. RSA dot pub The first one is a secret
file which we're gonna keep on our machine and we're never gonna share with anyone.
The other is a public file and this is something we're gonna share with both.
Get hub and her Roku so they can secure the communication between our machine and their servers.
The last thing left to do is to make sure that our SSA key pair is actually used the next time we set
up an SSA connection which we will be doing in the next two videos.
The first thing we need to do is make sure the program is running and then after that we're going to
register our new private key file.
So right here altogether we're gonna run the following command.
It is e Val.
Now if you are on Windows you're going to leave the next character off if you're on mac or linux.
You add the quote in after that it is dollar sign open and close parentheses.
Then once again on windows nothing on Mac and Linux.
Add that quote in then inside of the parentheses the command which would be SS H agent asked to start
that up.
So all this command is going to do is that's going to try to start up SS H agent if it's already running
it's going to simply tell us that by printing the process I.D. if you're on Windows you should have
this command minus those two quotes.
I'm gonna go ahead and run it.
And what do I get.
I get Agent PD 8 7 4 3 which means that things are already running after running this command.
The last thing to do is to register the file that's SS H hyphen at now.
If you're on a Mac you have to use the hyphen capital K a flag.
This is going to make sure that things get added correctly.
If you're on Linux or Windows you do not want to use that hyphen capital K as it'll cause a problem.
From here we simply provide the path to that private key file dot pub is the public one the other one
is the private one that is Tilde forward slash dot SS H forward slash I d underscore R S A when we run
that command we can see the identity has been added now when we try to facilitate an SS H communication
we'll be able to do it securely using our key pair.
Now at this point we haven't actually used the key pair to do anything in the next video we're going
to address that by getting our code pushed up to the github servers.
I'm excited to get to that let's go ahead and jump right in to the next video.