Creating Public/Private Keys on a Mac
In this lesson we create a public private key that will be used to protect our access to our server. Our first step will be to create a new private/public key using the mac terminal :
ssh-keygen -t rsa
Video Transcript
00:00You want to watch this video only if you're a Mac user or a Linux user
00:04but really it doesn't hurt to watch this but really this is only actionable to you if you're a Mac or
00:12Linux user if you're a Windows user just follow it to the next video where we'll see how to do these exact same steps
00:18Only they'll look completely differently when you do it on a Windows system
00:22Okay
00:22So what I want you to do is go into your terminal and go into your home folder the way you get into your home
00:28Folder it's just by typing CD and that strudily line not strudily this wiggly wiggle
00:34Which you use the shift and the comma the letter that's next to the one character and that will take you to your home folder
00:41Now before I do anything else
00:43I want to make sure or I want to check if I have a dot SSH file now by default
00:49Automatically when we're gonna try to connect from a Mac to our ARG server
00:54It's gonna go to that folder and see if we have a key pairing to send to the server
00:59And that's gonna be instead of a password or on top of a password either or so what we want to do is we want
01:04To see if we have a dot SSH folder
01:07The only reason why we would have one is if we already set up another server previously and by the way
01:13You could use the same key for multiple servers because you're it's really just what you have here as a private key a public key
01:20And you're sharing the two among the different
01:23Operating systems between your operating system and the server that you're running
01:27So really the old the you only need to create a new public private key for every computer that you're using
01:33And then you add that computer into your server saying hey these computers are allowed to have access into the server basically instead of
01:41Enabling users with a username and a password meaning anyone could access from any computer only a person that has
01:49Privileges of access could then access the server now
01:52It's really important when we're talking about something like that is that if you lose the only one computer that has access and you
01:59Don't have the private and public key anymore then you're scruggled
02:03So we really want to make sure that you make a backup of it and make sure that you have at least one computer
02:08But it probably at least two computers. So if one computer disappears, you always have another way to access your server
02:14It would be horrible if you have absolutely no way to access your server
02:18By the way, that's not oh, it's not automatic you can happen that way
02:21But it to improve the protection of your server
02:24Do we want to limit the ways and limit the access that users have to the server?
02:29All right with that intro done. We'll talk a little bit more about that later on when the windows users join us
02:34Let's start creating that private and public keys
02:37So the way I'm gonna do it and what I'm gonna do right now is I'm gonna create a new folder
02:42So I'm gonna create
02:45MKD or we're gonna make a directory and we're gonna call that directory dot
02:51SSH which is inside of our home for directory. I'm gonna go right into it and
02:57While when I'm inside here, it's that's it now I'm in the folder. I'm inside of the
03:03SSH folder and it's time for me to create that public and private keys very simple the way we create it
03:09We'd call the command SSH
03:11slash dash
03:13keygen
03:14space minus T for the type and the type we want to use is RSA which is the
03:20Version 2 of the protocol there are two different ways of two algorithms. The protocol 2 is more secure more robust
03:27That's what we want to use
03:29So we're gonna click on enter once we do that. It's gonna ask us what name do you want to give the file?
03:33We're gonna give it just one name the name that's there
03:36We're fine with it and do we want to put a password for it
03:39That's just an extra security if someone comes on your computer without privilege to access your computer
03:44It would give you a little bit more security. We're gonna
03:47Skip this by just not doing anything and typing enter enter twice. That's it
03:52We created our key last step is we want to upload this onto our server
03:57So to upload our key onto our server
04:00What we want to do is we want to grab the file and if you remember in a previous video a previous session
04:06We've installed a new application which enabled us to use the command
04:11SCP which is natively available on most Linux's and also on a Mac
04:16So we're gonna type SCP and we needed that application also on our server so we could send files from one end to the other
04:23So what we want to do is we want to go by the way before we even do this
04:26Let's just look at this. We have your two files one is called ID underscore RSA
04:31And the other one is called ID underscore RSA dot pub
04:35The dot pub is the public file where you're gonna share with the servers that you want to have access to your private key
04:41You don't share with anyone and that's the key want to store on your system and make a few cloud backups also
04:47So you never lose them maybe in your some sort of security and you're someplace that's safe
04:51Okay, so let me I'm just gonna clear the screen because we're getting too close to the bottom of the screen here and
04:57Let's move that the files or copy the files onto our server though only one file the public key
05:02So I'm gonna use the secure copy command, which is SCP and I'm gonna select the file
05:07I want to send out and that file is
05:10What's an ID?
05:12RSA dot pub, which is the public file
05:15Next I want to go into my host itself and I want to go into my user demo and my host ID
05:22I don't remember by heart
05:24So let me quickly go back back back until I find one of my logins and here we go
05:29I have here my logins
05:30I'm just gonna copy my IP gonna copy it and scroll all the way back and by the way
05:35What I'm doing is just using the back and forward just like we did on on the Linux
05:39Same as the Mac because the Mac is a variation of a Linux device. All right
05:43So now we have here we set our IP address. I'm gonna put here a colon
05:48Slash want to go to the home folder and inside of my demo folder in the home folder
05:53And that's where I want to send this file onto and all that's left for me to do is click on enter
05:58I'm probably going to be asked to authenticate myself and it's asking me do I trust this connection and I do and
06:04it's asking me to for my password and that's exactly what I'm gonna do next and
06:10It completed sending the file to the server now if I log into my account again
06:15but this time I'm gonna log in as as demo not as root and when I log in as demo and
06:23Go into my account and I do a search in my folder
06:29Oops, I didn't type my password correctly
06:33There we go
06:34And let me just clear here if I do a search with LS
06:37You'll see that my file is right there. The public file is right inside there
