[Music] hey what's going on guys in this crash course we're going to look at SSH or secure shell which is something that is extremely important to understand at least at least know the basics in web development and I know that when I went from using FTP to using secure shell and a terminal it confused the hell out of me and I like to make videos that I would have wanted to see back then videos that could have helped me so that's what we're gonna do we're gonna go over a few things we're gonna first look at some slides and just talk about what SSH is what it's used for and so on and then we're gonna jump into logging into a local bun to server with SSH so a local server that's on my network and we're gonna create some SSH keys so that we don't have to use a password we can just we can use those keys well get that will generate a set of private and public keys and then after that we're going to move to a remote digitalocean server or droplet as they call them and digitalocean is a great hosting service to host any kind of application and they basically give you these little servers and you can SSH into them and install what you want no js' or a lamp stack whatever whatever type of app you want so we'll do that and then I'm also going to show you how to set up SSH keys with github so that you can clone repositories and stuff like that without having to use your password your username and password and you guys have probably done this before but just for the people that haven't so hopefully you guys like this I've been asked to do more DevOps stuff and I think this is a good place to start so let's get into it all right so we're gonna briefly talk about what SSH is we're not going to get into like specific encryption methods and real advanced stuff this is to learn the basics and the fundamentals and how to use it so it stands for secure shell and it's a protocol to communicate with other computers similar to HTTP HTTP FTP these are all different types of protocols that communicate in different ways for different reasons so with us SSH we can use it for pretty much anything as far as creating files on other computer there's folders and files installing programs running programs deploying applications for the web and setting up web servers pretty much anything you want and what's great about it is it's secure it's encrypted okay all the traffic is going to be encrypted there are other protocols that are similar like telnet where you can log in and you can do this stuff but it's not safe because it's not encrypted people can can basically hijack your your sessions and things like that so SSH is definitely what you want to use for this type of stuff now SSH is usually used in a remote command line or Terminal session but it can also be used with SCP or secure file copy and you can there's actually GUI programs where you can basically drag-and-drop files to your server that way and and winscp for Windows is one of them that I can think of one of the clients that I can think of and then you can also use it with FTP there's something called secure FTP where you can use something like FileZilla which is an FTP client you can set it up to use SSH in SFTP and transfer your files in a more secure way so we'll be using will be just sticking to the terminal for this video now you can't just log into any machine on earth with SSH even if you have the credentials the server or the machine that you're logging into has to have something called sshd or open SSH daemon which sits and listens for SSH connections okay so usually it's a Linux server you're logging into and with something like let's say a bunch of server which is the operating system that my local server is you running that comes in with sshd so it's not something that I had to set up it's just automatically installed I think with the desktop version of a bunty you have to install it using your package manager I'm not positive about that but I think that's the case and then on the server you also have an sshd config file where you can change things like let's say if you want a disabled password login for the root user to prevent brute-force attacks and you know just make other security provisions on your server you would use that file to do that so obviously you need a way to authenticate with your server you know authenticate using SSH and there's a few ways to do that you can use the password which is basically the default way of doing it where you have a user on that that remote server and then you have the password for that user and then to login what you would do is just use the SSH command you would put the name of the user you want to log in as and then at and then the host name or the IP address like this so this is actually the local IP address of my AB unto server so this is how I would log in and then once I did that if I didn't have SSH keys set up which I'll talk about in a second it's gonna prompt me for the password and then I put the password and it'll show me a welcome screen in the terminal and then I can go to town and create you know create applications or whatever I want to do on that server now another way that you can authenticate is by using SSH keys and you can bypass the password altogether you just simply type this in and it'll let you right in and the way that you do this is by generating a set of public and private keys on your machine and I'm going to I'm going to tell you how to do that in a second but that's that's the recommended way of doing things it's safer than using passwords people can brute-force attack passwords and things like that and then you also have host based authentication where it goes by the host so you have a file you have a file called known hosts which store any hosts it's allowed to connect to that machine but we're not going to get into that we're going to stick to the password and SSH keys all right so to generate these keys it's pretty simple all you have to do is run this SSH key gen command and basically what it's going to do is it's going to create a public key and a private key it's gonna create it by default right in your home folder or your user folder which is this tilde that's what that represents and then it's going to be in a folder called dot SSH ok now the dot means that it's going to be a hidden folder by default so if you're in like Windows Explorer or on your Mac in the finder or whatever unless you have hidden files enabled you won't see this and then inside there it's gonna create a file called ID underscore RSA ok that's the default name for your SSH key and it will prompt you when you run this command here it will prompt you to see if you want to call it something different but this is the default and then your public key is going to be in the same location it's gonna be here the same name except it's gonna have dot Pub after it ok so the dot Pub just tells you that this is the public key and this is what you actually want to put on your server ok now on your server you'll also have a dot SSH folder or you'll create one if it doesn't have one yet and then you'll have a folder and they're called authorized keys and that's where your public key goes ok so that's how the server knows if if the machine that you're logging in with actually is authorized to do so ok and I'm going to show you how to do all this so don't worry if this is confusing you so what about windows ssh the command itself is a unix based command it's always been available on unix and i'm sorry on linux and mac because they're UNIX based systems however Windows didn't support native SSH until very recently so on older versions of Windows we would use something called putty and puttygen puttygen was used to create the keys and then putty was used to actually connect to the server and it's a GUI program it is a graphical program but it's a pain in the ass to use it's I hated it when I used to use Windows like before SSH was available before get bash was available and stuff like that but if you are on let's say Windows 7 or Windows 8 or something like that I don't believe the SSH command is available on those systems so you will have to use something like putty but I would recommend using git bash which isn't just an awesome terminal program and I'm pretty sure you can use it on windows 7 and 8 it's just been so long since I've used those operating systems but that should give you the SSH command and then anything I do in this video on in on my Mac you should be able to do on Windows as well all right so we're gonna get started like I said we're gonna start with a local server that's on my network and then we're gonna move to a remote digitalocean droplet I'll show you how to create SSH keys how to do a little bit of provisioning on the server how to create SSH keys for github and add those to your github account and maybe a couple other things as well so let's go ahead and get started with that alright guys so we're gonna get started now I'm gonna be typing in a ton of commands so I'm gonna put a gist file in the description so that you guys have all the commands as of reference so if you if you're following along or if you just want it as a reference for future projects or whatever so what we're gonna do like I said we're going to start with the local server I have in a bunch of or on my network it's a virtual machine but it has its own IP address so as far as the network knows it mean it doesn't matter if it's a physical machine or a virtual machine so we're gonna start with that and then we're gonna move to a remote digitalocean droplet and we're gonna work with that we're going to we're also going to work with github we're gonna add we're gonna add our SSH keys for our server to github so that we can do clones and we can we can work with github on our server so basically what we're gonna start off with is just logging in with SSH to our local server so to do that we use the SSH command and we want to put in the name that we want to log in as so this name is what I used when I created the abun to server and then we want the IP address of our host name in this case the IP address is one nine two one six eight one two nine alright so once I do that we're gonna get this message and you're only gonna see this the first time you try to SSH into a server and if we say yes it's just gonna add us to the known host file now it's gonna ask us for a password to authenticate so this would be the password for Brad on this system on the server okay not not the machine and come on not my local machine ok so now you can see we get greeted with this little welcome page and it just tells us like the the server version so 18 Donald or it gives us like some system information memory usage shows us the IP address and then down here notice that it says Brad at dev web server so that's actually the name of mice my local server and that means that we're now inside of that server we're no longer on my local Mac okay so I'm gonna just clear this up and if I do an LS you see there's nothing here we're in the home directory my home directory on the server now if we wanted to go to the root we could CD to forward slash and if I do an LS you'll see all the core all the root Linux files are in folders so Etsy bin dev all these folders and we can do whatever we want as long as the user on the server has the permissions we can do whatever we would like as if we were right in front of the machine I have a linux server that I ran for years that has all my media all my you know music and movies and stuff and it never had a monitor it was headless so I don't only use SSH to manage it to log in and manage it in addition to some browser-based tools like plex for media streaming and stuff like that so let's go ahead and CD and that'll bring us back to our home directory and then we can obviously create folders so if I make a directory called test and you can see that was created we can see the into test we can create files so touch test dot txt that will create a test txt file all right so you know just like it just we can do anything as if we were logged in and I'm just gonna CD back to the home directory and I'm going to remove that test folder so we're gonna do remove and then since it has something in it we're gonna do - RF and then test and if we do an LS now that that file and folder is gone okay I do have a if you're interested I have a command line tutorial on my channel I did probably about a year and a half ago that that I think it's pretty good and gives you all the basic commands to move things around and copy files and and all that stuff so let's go ahead and install something I want to install an Apache server so I'm going to open up Rome so it's and I'm gonna go to that IP address by local IP address and notice that nothing happens that's because this server doesn't it doesn't have any web server installed on it so I'm going to install Apache so let's go ahead and do sudo because we want to we need to run this as root just like on your Mac and then we want to do apt install okay so apt is our package manager and we're saying we want to install using our package manager Apache - oops I spell that right patchy it's hard to talk and type at the same time and then I'm gonna do - why to answer yes to any questions put in our password there and then it's going to go ahead and install Apache on the local server and I mean you could set up a whole lamp stack you could you know create mean stack applications whatever you want to do Python Django you can do anything so now that Apache is installed if I go back to my browser and I reload this page we're gonna see the Apache start page okay so once you install Apache this will automatically be put into your VAR /ww slash HTML folder which is your web root okay so just to show you that we can install stuff and we could access this IP address from anywhere on my local network if I go down to my living room as long as it's on the same network I can go ahead and I can access this and we could create web applications locally if we wanted to and of course use it for other things like I said I have I have a Linux media server so you can do whatever you want with with a server like this so what I want to do now is create some SSH keys because right now I mean we can exit if we type exit that takes us back out you can see now it says brad's I Mac Pro so we're now we're not in the server anymore but if I were to try to log back in I'll have to put in a password so what I want to do is generate SSH keys so to do that we use SSH - key Jen okay so if I go ahead and I run this it's going to ask us where where we want to save the key and what file we want to save it as so the default is going to be in your whatever your home directory for your user you're logged in user and then dot SSH which is going to be a hidden folder by default and then the file name will be ID underscore RSA okay so that's going to be the name of the private and public key the public key will just have dot Pub after it so I'm going to keep the default and just hit enter and you can also attach a passphrase if you want I'm not going to so I'm just going to hit enter twice and then that should create our key so if we were to just do an LS into dot SSH oops LS dot SSH you can see that we have the private key here and the public key if we want to take a look at what the public key looks like we can use the cat command which will just basically display the contents of the file so we'll say cat dot SSH because that's the folder it's in and then ID underscore RSA dot Pub and there it is so that's what our key looks like our public key a private key is a little longer the private key you don't do anything with you just keep it on your system so now that we have this key on our local system what we need to do is get this public key onto the server so like I said in the slides the where this needs to go is into dot SSH folder on the server and then if I in a file called authorized keys so I'm actually going to go to a digitalocean documentation page real quick so if you search for create SSH keys and I'll put this link in the description as well it's the second one right here so it shows you how to generate a key they want you to use the T flag in RSA but that's fine and it generates the key and then to copy it to the server you could use something called SSH copy ID but you have to install that with homebrew so I don't want to do that because some of you might not be on a Mac and some of you might not have homebrew installed I don't want to go through that so right here it says alternatively you can use this so basically this is one long command that are a couple commands that is going to first take the content of the the public key file it's going to SSH into your server it's going to create a dot SSH folder on your server change the permissions and then it's going to put whatever is in that public key file inside of a file called authorized keys so this one line is going to do all that stuff for us and this will be in the gist in the description so I'm gonna go ahead and just copy this and then we'll go back to our terminal and let's clear it out and let's paste that in except we need to just edit whoops what happened here yeah I might have to paste it in to a file first yeah I'm gonna have to paste it into a file first cuz this is giving me problems alright so let me just open up sublime tax real quick let's see file new file alright so I'll paste it in here ups and then I'm gonna change this right here this demo at this address to mine which is Brad at 192.168.1.1 dot to nine okay so let's copy this and then hopefully that works and let's enter and it's going to ask us for the server password and we should be all set ok so it should be in the authorized keys folder on the server so I'm gonna close this up we don't need this so now we should be able to log in without a password so if I go and I do SSH Brad at 192.168.1.2 9 there we go no password needed we now have our key setup so if I clear this up and we go to let's do let's say cat because I want to display the contents of dot SSH I remember one we're on our server now and I want to look at the authorized underscore keys file and there's our key ok and just to double check if I open up another window another terminal on my local machine and I take a look at our public key which is in SSH / ID underscore RSA dot Pub there it is and you can see that it's the same exact key okay so that's how we can add keys and then we no longer need a password alright so let's see we're gonna do most of the stuff on that on the remote server because that's a that's more of a situation you'll probably have where you're deploying applications this is more of a local type thing but you can do anything you want here so I just want to show you one more thing if we wanted to let's say copy a file from our local machine to to our server to our dev web server I'm gonna exit out of here so I'm back in my iMac and what I'm gonna do is just use the actually let's create a file let's see what we have here I already created this move dot txt file but if you want to create and create a file you could say touch I'll just use test dot txt so now we have this file test txt and if I want to move it I can actually use secure file copy so I can do that with the SCP command and I can say I want to move it from the home directory and then it's test dot txt and I want to move it to my server which is gonna be Brad at 192.168.1.2 9 and then I just want to put a colon and then where I want to put it which is gonna be in the home folder on the server ok so let's go ahead and run that alright and then if we log back into the server I'm just going to go like that and we do an LS you'll see there it is there's our test dot txt file so we move that file from our local machine to our server very quickly and you can easily do that with with folders and files and there's there's a lot of different ways to do it you can use our sink and there's all kinds of commands that you can use so now what I want to do is exit out of this and let's clear this up and now we're gonna start to work with a remote digitalocean droplet so if I go to my digital ocean panel now let me explain a little bit about digital ocean it's a hosting service they offer droplets which are basically just little servers they're virtual servers just like I just showed you except it's remote it's it's online and you can do applications to it and you can choose to use Linux Ubuntu you can use there's other distributions you can use as well and basically when you sign up you'll go to digitalocean comm sign up you'll add your credit card information and they're not gonna charge you anything when you sign up once you sign up you just go to create droplet and you go down and you choose a package okay so I'm actually going to give you a link in the description for ten dollars so you get free ten dollars and you can choose the first package here which is five dollars per month so that link will give you two free months of hosting and the $5 per month obviously isn't good for like a big production app but for testing for stuff like that and it's absolutely fine and if you don't use up to a certain point they don't even charge you the five dollars you get like a point zero zero seven cents per hours so they're actually really cheap for what they give you and if you wanted to you can add go to one-click apps and you can have like django installed lamp stack mean stack docker you can use all this stuff make it all pre-installed when you set up your server but we're not going to do that I just want a plain abun - server okay so I'm going to choose five dollars a month I'm gonna just leave all this stuff and what's cool about this is we can we can do our SSH keys like we just did through the through the terminal if we want but we can also do it this way so we can add a key here and that's what I'm gonna do so I'm gonna go to my terminal and I could use the same key okay remember we created the ID underscore RSA public and private key I could just take that public key and put in here but I like to keep keys separate for for separate things okay so what I'm gonna do is generate a new key for digitalocean so I'm gonna do SSH - key Jen and they want you to do this TRS a and it's going to do the same thing it's going to ask us what we want to call it now if I if I just hit enter it's gonna ask if I want to overwrite the current one because I already have one called this so I'm gonna change it and you want to put the whole path so users slash whatever your user let's see they spelled my name right and let's do slash and then dot SSH and then what I'm gonna do is I'm going to call this ID underscore RSA underscore do for digitalocean okay so it has a different name than the other one so let's go ahead and run that and not going to use a passphrase and then if we were to list the contents of dot SSH you can see now we have the the digitalocean public and private key as well as the other ones so now we want to do is we want to take that public key and we want to put it into digitalocean so i'm going to do a cat dot ssh there's other utilities you can use like pb copy and x clip if you want but those aren't available on windows so i'm just trying to make this cross-platform so we're just gonna do cat and then let's make sure we get the digital ocean one which is RSA underscore do and we want the public key of course okay so what I'm gonna do is just grab that make sure you don't leave any spaces at the end or the beginning has to be exact so I'm gonna copy it I'm gonna go new SSH key paste it in and we'll just call this key one doesn't matter what you call it and we'll add it okay so now down here it's going to ask us to choose a hostname I'm just going to leave this crazy hostname that's fine and we'll click create okay so it's gonna just go through and create our server for us or a droplet as they call it and this code learner dotnet that you see you can put you can connect domains to droplets and I had this one connected before so that's why it's listed here any domains you have connected to your droplets will show up here okay so I sure server is now set up or our droplet and has this IP address okay this is the IP address of the droplet and if I click on it we have all types of information since we just set it up the CPU and stuff isn't going to show yet but you can see we can launch a console when the brow we can reset the root password we can power it off we can resize it so if you if you have a production app and it's it's getting too big for let's say the memory you have or the disk size you can upgrade that easily and same with CPU stuff like that there's also backups recovery you can take snapshots so it's it's a really great service it's definitely one of my favorite hosting services so now that we have this server let's try to log in now remember we have the SSH keys so we should be able to log in without a password so let's go ahead and clear this out and let's do SSH now it's going to be the root user okay so it's going to be root at and then the IP address which is this so I'm gonna copy this and paste that in and let's see what happens so we get this message we want to say yes and then we're going to get this permission denied public key okay so you may or may not get this the reason we're getting this is because we used a new key called ID I RSA do so what we need to do now is just run SSH - add and then we want the location of the key and then the name of the key so we want to do home slash dot SSH slash ID underscore RSA underscore do now we don't want to do the dot pub here when we do the SSH add you're just adding the key like this so let's run that and it says identity added ok so now we're gonna go and we're going to try again to SSH into our server and now it works ok so we get this little message just like we did on the local server it is using 16.04 not the latest but you can see right here we're logged in as root at a bun to whatever a bunch of gibberish so we're now on our digitalocean server it's that easy so I'm going to clear this up if I do an LS there's nothing here we can go to the root and you can see all the root folders ok let's go back to the home oops I want to just clear this up all right so we're logged into our server now let's see what do we want to do next we don't want to actually first thing I would do when I get a server is I would update my packages so I do sudo apt update and that's just going to take all the packages that are installed and make them to the to the latest version and then we can run sudo apps upgrade to actually upgrade the software I mean I didn't have to do this for the tutorial but it's something that you should do once you create your server just so just so everything's up to date so then you would do sudo apt upgrade should've did yes that yes flag all right so that'll upgrade everything and then what I want to do next is I want to create a new user because you should never use the root user so we're gonna create a new user and give it sudo privileges so that it can the user can run programs as root and a lot of digitalocean tutorials don't actually do that they don't tell you that or show you that so I'll try to do things right I also want to disable the root the root log in so you can't possibly even try to log in with a password with the root user okay so if we get if you get this this is just asking about the the grub menu just keep the local version installed just hit enter twice okay so now that everything is updated what we're gonna do is like I said add a new user so we can say add user and I'm just gonna call this user Brad okay so it creates a new user Brad a new group Brad and if I do ID oh I'm supposed to put a password in loops I already typed something let's try again yes all right so I'm gonna put a password in alright it's gonna ask some questions all I do is put my name in and then enter through everything else all right so now if we do ID Brad it'll show us that there's a user and group named Brad but we don't have sudo privileges yet so what we want to do is let's do user mod and I'll have all this stuff in the description so don't worry about that and you want to add lower case a and upper case G you want to add these flags and then sudo and then the username that you want to add the privileges for which is Brad okay once we do that if I do ID Brad again you'll see this sudo right here okay so that's what we want so now what I want to do is login as Brad so I'm going to exit out of my digitalocean server and let's clear this up and let's try to SSH in SSH with Brad at and then whatever the IP is let me grab that so what's going on here is we're getting a permission denied for our public key because when we added our public key to the server we added it for the root user every user you have if you want to use SSH you have to add the key to their specific SSH folder so what we need to do is log back in as root okay so we're going to log in as root which our keys are all set and then we're going to CD I'm just CD into slash home slash Brad okay so now we're in Brad's home folder and we want to now create a directory so make directory dot SSH and then we need to have our own authorized keys file for Brad so let's let's just CD into dot SSH and let's go ahead and touch which creates a file authorized underscore keys spell that right ok so now we should have an authorized keys file and now as you can probably guess what we want to do is paste in our key so let's go ahead and let's see how do I want to do this let's open up another terminal and let's get our key so I'm going to do cat dot SSH slash and then I want to make sure I get the digitalocean key so it's ID underscore RSA underscore do dot pub okay we want the public key we're gonna grab that and we're going to copy it and then we're going to go over here and we need to get this key into the authorized keys file so what I'm going to do is sudo nano which is a terminal base to edit our text editor and then authorized authorized keys okay so now I'm just gonna paste in my key you can't see it all but it is here if I go over you'll see it's all here so I'm gonna save this with control command control X say yes enter and now it should be in there so if I do a cat authorized keys now you can see that it's in there so now I should be able to log in as Brad to SSH so let's go ahead and exit okay we'll exit the root user I'll clear this up and then we're gonna SSH as Brad actually I'll just hit the up yeah right here so now let's try this and it works and you can see now we're logged in as Brad alright so it's simple as that so just remember your keys your public key that's on your system on your local system just needs to be in the server's authorized keys file and then you're all set so what I want to do now is I actually want to disable the root password login so remember I told you there's an sshd config file so I'm gonna do sudo nano sshd not sshd it's in the Etsy folder so we want to go /et c / ssh /s s HD underscore config and let's put in our password okay so this is the config file there's a lot of stuff you can change in here by the way port 22 is the default for SSH in case you were wondering 21 is FTP 22 is SSH and I just want to go down to let's see I want to look for a root log in right here permit root log in so right now you can you can attempt to log in as a root user with a password but I'm gonna set that to no because that prevents brute-force attacks and stuff like that and there's a lot of other stuff as well I'm not going to get into and then I'm gonna make sure that password authentication is set to know which it is already so yeah so let's save this command ctrl X and yes and now the nobody can log in with a password with the root you have to use SSH key okay and then we should just reload the the sshd service so we can do that with sudo system CTL reload sshd and that will reload it and I don't expect you to remember all these commands like I said I'll have a reference sheet in the description so now let's see what do we want to do next let's let's actually install Apache just like we did on the local server so we can do sudo apt apt install Apache - - why and then once that's installed we should be able to go to our IP address which we'll grab right here in the browser and paste that in and there we go we have an Apache start page so this is live now this is not no longer a local server that's on my to my network this is live and we could keep we could go through digitalocean and add a domain to this so that you could go to whatever something calm and you could have your application so you could create a lamp stack install node whatever you want I'm actually going to show you how to install node and also deploy a react application so I mean what we do from from here on out is is just kind of extra I've already basically went over the basics of SSH so you know creating the keys and uploading to the server stuff like that but what I want to do now is I want to be able to use github on the server so I want to be able to clone a repository and stuff like that so we have to create keys for github because if I try it now and we have git installed it should be so if we say get version you can see it is installed but if I try to clone a repository like let's say let's go to let's go to my github and I'm gonna grab this react odka so this is a react application that doesn't have a back-end it uses odka as the back-end so you don't actually need to like have a node API or anything like that so you can build it to a static folder but what I want to do is try to clone this on to my server so I'm gonna go to clone I'm gonna grab make sure it says clone with SSH and then let's go ahead and let's copy this and then let's go into our home folder and we'll say git clone and we'll paste that in and run it okay we'll get this which say yes and notice we get this same thing we've seen before permission denied public key because we don't have SSH key setup with github so let's go ahead and do that so we're gonna do SSH - key gen - T RSA and then like I said before I like to create separate keys for separate services we have one for the local server we have one for digitalocean now let's create one for github so I'm gonna do and remember we're not we're on our server now so it's in home slash Brad that's the Linux structure rather than users slash whatever and then we want dot SSH and then slash and let's call this ID underscore and you'll have to do this on your local machine if you want to use github with SSH on your local machine as well so let's do ID underscore RSA underscore github okay so we have an issue here we get failed permission denied now the reason for this is because the dot SSH folder is it's under the root user and the root group in fact if I do let's see let's do LS I'll say LS dash L not LS yes LS but we need the a as well because it's a hidden folder there we go all right so let's take a look here so everything has Brad Brad this is the user in the group the dot s SH has root as the the user owner and the group so what we want to do is change that to be Brad Brad instead of root root so we can do that and and I know this is a lot is a lot of stuff going on here a lot of commands and it's overwhelming but I do have the the gist and everything should be in order for you to for you to check that out so we're gonna say pseudo and we're gonna do challenge so change owner so chown and then we want to do recursive we want this to basically change any everything that's in the home Brad folder so we want to change it to the user Brad and the group Brad and the folder we're talking about is home slash Brad so everything in there we want to change to Brad Brad all right so let's run that and then we can do our LS dash L a again and now notice the SSH folder has Brad as its owner and group so now we should be able to go ahead and generate the key so I'm going to go back to this right here SSH key Jen and again home Brad SSH / ID RSA underscore github and now it works okay so now if we were to LS dot SSH you can see we have our key our public and private key for github in addition to our authorized keys file that's that's on our server so now what we're going to do is take that public key and we want to put that on to github so let's do a cat dot SSH / ID underscore RSA underscore github.com okay so this is our key we're gonna grab this so we want from here to here and we'll copy that and then in github I'm gonna go to my settings I'm gonna go to SSH and GPG Keys I'm gonna say new SSH key you can call it what you want I'm going to call it actually already have do server one digitalocean server one that's what I'll call it and I'll paste that in okay make sure there's no like extra spaces here or anything all right so let's add that key and now let's go back and let's clear this up and then now let's try to clone that repository so I'm just gonna hit the up arrow till I get to my clone that I did which is right here and hopefully it works so yes and it didn't okay now we did this this happened to us before I remember with digitalocean we had to do the ssh ad so we're gonna do that same thing I'm gonna say SSH - ad and we want to add slash home slash Brad slash dot SSH / ID underscore RSA underscore github like that could not open a connection to your authentication agent alright so if this happens then we need to run eval we got to do eval and then we want to put in a set of backticks and then we want SSH - agent and then - s to activate the SSH agent so it gives us the ID and now we should be able to run our ad and there we go identity added ok so again I'll put that in the gist so now that we have our identity added we should be able to do our clone finally so let's clear this out and let's go to our clone and run it and there we go so now if we do LS we have the react off application inside our repository inside of our home directory alright so what I want to do now is CD into that so react off and if we do an LS you'll see this is this is actually a react application so we do need nodejs installed so that we can run npm install it needs to look at the package dot jason and install the dependencies so we don't have n PM we don't have node installed so to do that let's go to once actually we don't need this page anymore so let's just search for install node a bun - because if you want the latest version and if we go to Debian and Ubuntu based distributions which is right here if you want the latest version you actually have to use the curl command and you have to use this Deb dot node source and then you want to put the version you want here I want version 10 which is the latest so I'm gonna copy this and then go into my terminal and paste it in and just change the 8 to a 10 because I don't want version 8 I want version 10 dots whatever the latest version of 10 is so we'll run that and what that does is it adds it to the the repo list and now we should be able to install it by saying right here it'll show us apt-get install nodejs okay so we'll say sudo you don't have to do get anymore you can just do apt install node J s - why and now this will install node and NPM all right so if we say node version there it is 10 6 0 so we're in the react folder so let's do NPM install which will install all of our dependencies and like I said this the stuff we're doing now isn't I mean yeah the SSH tutorial is basically over this is just stuff to show you some more you know some more DevOps stuff because this stuff gets confusing to me DevOps is is you can get more complicated than web development and coding okay so we have all of our dependencies installed now we can run the dev server if we do npm start this is a it was built with create react app i do have a video where we created this application okay so it'll start the development server okay now we can go to our IP address and then go to port 3000 and there it is there's our Acme staff portal and like I said this this uses a service called Auto where you can log in you can manage basically a user management system and I do have a video like I said creating this application now you don't want to run this like this since this is a react app what you would want to do is build out your static assets and then upload that and then serve that instead of this port 3000 this is the dev server I just wanted to show you that you can do that so let's go ahead and actually deploy it so what I'm gonna do is get out of this so ctrl C and let's move this remember we have Apache installed so with Apache we have a file in var var /ww slash HTML if we look in there that's the index.html that's the the Welcome page the Apache welcome page so what I'm gonna do is I'm going to remove this index.html file from here so I'm gonna say our M which is the remove command and then we want VAR w w / HTML / index dot HTML we want to completely get rid of that rule yes and I'll just make sure it's gone which it is not and that's because I forgot sudo all right let's make sure it's gone okay so now that that VAR w w HTML folder is completely empty what I want to do is I want to build out our react application so we can do NPM run build and what that's going to do is it's going to take our application and it's going to create a production build so it's gonna build out all the static assets that we need and it's going to include an index.html file that will be you know connect to the the compiled JavaScript and it will be our application and we can just upload it anywhere including our Apache server okay so once this is done is done building what we'll do is we'll just move the contents of it to the VAR WW HTML folder and we should be able to access our application just by going to our IP address alright so now that that's built if we do an LS you'll see there's a folder called build so what I'm gonna do here is I'm gonna say sudo I'm gonna use the move command MV and I'm gonna use the V flag and then just do slash home slash Brad oops should be slash so home slash Brad slash and then react odka off and then we want slash builds because we want whatever is in the build folder so let's do slash star which will means everything in there and we want to move it to VAR w w slash HTML okay let me just double check that make sure didn't make any mistakes so it'll take everything in the build folder put it into that into our web root basically so let's run that alright and now if we do an LS of the web root you can see what's in there index.html and then we have a folder called static which has all of our static assets for reacts so let's go now to just our IP address no port 3000 no dev server and run it and there it is there's our application so if you wanted to add a domain which you probably would if this was going to be production you would go to networking and then add a domain now of course you have to register your domain somewhere and then what you do is you point your name servers your DNS I'll just show you for an example for my code learner net you want to point your name servers to ns1 ns2 and s3 digitalocean com and then just add in a record you can put in your just an @ symbol here and then choose the droplet you want and add that record ok and you can do that and you can you can then have a domain so I think that's that's all I want to do guys this went longer than I thought I just wanted to throw in a couple extra things some extra develop stuff just to kind of get you familiar with how things work but yeah you can use digitalocean droplet to build anything you know if you're building a django app or an OU JSF react angular full stack whatever you can do whatever you want PHP lamp stack so hopefully this tutorial helped you in terms of SSH so you learned how to log in how to create keys how to deal with like you know adding keys and stuff like that permissions and and a bunch of other stuff so in setting up github which is very important and again if you want github keys set up for your local machine you'd have to add that as well so you can so you don't have to add a password or anything or use HTTP so that's gonna be it guys thank you for watching thank you for sticking with me through the whole thing and I will see you in the next video