AWS How to Launch an EC2 instance? - Step by Step tutorial (Part-4)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome back to the AWS series and now in this chapter we are going to talk about the AWS ec2 instances so that is one of the most basic building block when you start working with the AWS which is ec2 in the previous chapter we have taken a look onto the sign up process how to create IM user and how to get yourself familiar with the IM roles and the policy now after that uh I think ec2 is going to be a good candidate to learn more about when you're trying to learn the a WS so in this chapter what we are going to cover today is like first of all I'm sorry let's go back to previous slide so first of all we are going to take a look like what is ec2 instance how to launch an ec2 instance and how to create your public key and private key and how to associate those public key and private key with your ec2 instance and once we attach those uh SSH key then we are going to take a look how you can SSH from your putty or from your terminal from your local machine to your remote EC C2 instance which is running onto AWS console so this is going to be a very basic chapter to get more understanding onto the ec2 instance so that you feel more comfortable in the upcoming chapter we will increase the complexity or the label on how to set up a E2 instance with the proper VPC subnet and all those things so we will take a look later uh on those in upcoming chapter but in this chapter we are just going to focus on the very basic few elements so that you feel more comfortable working with the ec2 instances to start with our ec2 instance go to your AWS console in the search box type ec2 click on this ec2 and here you will find this is the ec2 dashboard where you can see all the running instances uh which are presently working so right now this is my personal AWS account and here you can see instances running which shows zero so I don't have any E2 instances running so if you can click on this so here you can see the list of uh uh like this particular list will be filled with the ec2 instances and here you can see and get an overview that how many ec2 instances you are running since this is a uh like a personal account and I don't have many resources up and running here so what I'll do I'll just go back to ec2 dashboard once again and here you will find one option to launch a ec2 instance so here this is an orange button so just click on it and here you need to specify some parameter which is essential to start an ec2 instance so here first of all put a name so I will just put a test demo uh E2 instance okay that's done and that's the name which we are going to refer to refer for this particular ec2 instance the next thing which we need to do which we need to do is we need to select the image like what kind of a ec2 instance which you want to run so ec2 instance in the basic nutshell is just a virtual machine or a virtual server running on a AWS so if you talk about the server then you need to choose the base operating system like on which kind of a flavor you want so here are multiple options so we have a Linux from AWS we have a Mac OS we have a UB 2 we have a Windows we have a red hat we have Linux Su so there are many flavors which is available over here but since uh we are just trying to learn the AWS and in 90% of the cases we go for a Linux server so here I'm just going to choose Ubuntu uh because that's most like a used across uh there are Amazon Linux also which is quite popular but it just depend just choose any if you're a beginner just choose any Linux operating system which you feel comfortable working with so here I'm just choosing Ubuntu and if you're just trying to uh learn this or if you're just trying to launch this instance for learning purpose then I would recommend to stick with the free tier otherwise it will cost you uh some money because uh if if you go and choose the higher instances then it will cost a lot of money for a just for learning purpose so just stick with the free tire whenever it is possible for you all right so now I'm choosing the canonical UB 2 [Music] 22.041 instance okay let's move ahead so here I have choose the t2. micro so this t2. micro is the very small instance which is free from AWS although you can increase like a t2. small t2. large so those are uh like a higher uh CPU and memory instances which you can get but just stick with the t2. micro if you're just using it for a learning purpose so here I have just choosen t2. micro then the key thing comes over here is the key pair because once you start an ec2 instance or once you launch an ec2 instance then you should be able to SSH or you should be able to remote login into that ec2 instance and if if you don't set a key pair then you will not be able to do that so for that what we are going to do we just going to create a key pair I'm just going to explain how to what is public key and private key and how we associate them with so here I'm just going to click on create a key pair so I'm just going to put test demo key pair and you can just keep the option default that is RSA and Pam file that's a complete fine then create a key pairer and as soon as you create a key pair then it will uh download this particular key which you can see over here so here in my download section test demo key. Pam this particular file is a private file private key which you are just going to keep with you so this this file has been already downloaded for us let's go ahead uh yeah before going ahead I would just like to explain the concept of our key pair so so if I take the next slide so right now we have just generated a key pair so that key pair consist of a public key and the private key so when I have clicked on this create a key pair over here then it has generated two keys one is public key and one is private key so the public key is already uh present with the ec2 instance it's going to present with the ec2 instance but the private key is going to be with us so private key which we have already downloaded over here here so this private key we are going to use later on to SSH into this particular instance so that's the important concept to keep in mind I'm just going to show you like how we are going to do the SS and how we are going to use this particular private key and the name of the key is test demo key pair okay all right so let's move ahead and here these are the network setting so this is just a very basic session on ec2 so I'm just going to keep everything default over here I'm just not going to create any VPC subnet or Security Group just keep the things default over here the only thing which we need to keep in mind over here is to allow SSH traffic and just check Bo this one and click anywhere so what does it mean so it means that you're allowing to do the remote SSH or to the remote login to this particular instance once it is up and running and here anywhere 0.0.0 which means that you can sssh from anywhere in the world so if you select this drop down and if you put custom then here you can assign some specific IPS so here you can see my IP if I put this one then I will only be able to SSH or remote login into this server from this particular IP which is 82.1 1991 170. 75 so I will be only able to SSH into this server from this particular IP but since we are doing it for a demo purpose I'm just going to keep it anywhere click next and here you will see uh the configuration storage so here you can specify ify the uh the root volume like I'm just keeping the 8GB because I'm just going to use it for a demo purpose so that's the uh like a storage I'm just going to associate uh with my ec2 instance and in advanced detail I'm just going to I'm just not going to change anything over here just uh uh C keep it close and I think I'm done with all the information which is required to start and launch or start or launch an ec2 instance then I'm just going to come over here here and click on launch instance and it might take like a minute or so and after that your E2 instance is ready so here you can see it has started quite quickly and here you can see this is the ID which is the instance ID so either you can click on here and it will take you to the uh E2 instance dashboard and if you are not sure like from where to go onto this particular dashboard so what I'll do I'll just show you once again so click here Type e 2 over here click on ec2 and here you can see the instances running is which is one and just click on and here you will see the details so this is an ec2 instance which we have launched and if you want to check more details about this ec2 instance then just click on this instance ID and here you will find all the details so here you can see this is the public IP this is the private IP which has been assigned by AWS to this particular instance and the state is running so now we can SSH into our ec2 instance using our uh private key which we have just downloaded over here all right so now you can see uh we are able to successfully launch over ec2 instance and the platform is U to platform uh the uh type of operating system we are using over here is Linux and the version of UB to Linux is 22.4 so these are just the primary details which are available with you and also here you can see the key payer name what is the key payer name which we have associated with it so this is a good a handy dashboard which comes quite handy when you want to troubleshoot and when you want to perform some kind of Investigation onto your ec2 instances now the important question is like how to SSH into my ec2 instance so here just click on this instance ID and here you will find an option to connect so click on connect and here you will find SSH client this is the option which I would be interested in so here you need to follow this instruction so here first of all it says you need to change mode of your private key which you have just downloaded so if you remember that in the previous step we have downloaded this particular uh key so what we need to do we just need to open a terminal so here I have open this particular terminal and just check the path where my file exists so here you can see this is the path and I'll just run the ls command LS LT and here you can see this is the test demo key PA file which is a private key which is uh present onto my local laptop and the thing which we need to do is we need to change the permission the permission right now which is default which is quite open and we just wanted to reduce this permission so here you can see the these are the permissions so what I need to do is I just need to go back over here just copy this particular command so CH mode 400 and then run the command so I'm just going to do this one and just hit enter and just run the lslt and here you can see the previously it has a read write permission but now it has only the read permission so once you change this permission then you should be able to SSH into your AWS ec2 instance I'm just going to clear this instru uh screen over here and go back to my instruction so here uh this is the SSH command I would be interested in so just copy this particular command I'm just going to explain like how this command works so I'm just going to head over to my terminal I'm just going to paste the command so here if you take pay attention so SSH is the uh command then I and then after that here I'm specifying my private Keys remember I'm into the same directory so I just using the file name over here and after that I'm just using the ubun 2 ubun 2 is the user uh which is created by default when I spin up my uh EC uh ec2 instance so this is the default Ubuntu user which I'm using and this is the public uh IP address not IP address but with the public DNS name which I can show you also so here go to the instance and here you will find the public IP for DNS so this is the public IP for DNS for that particular instance either you can use this public IP uh for DNS or either you can use this public I IP uh 4 address also that's both are fine so I'm just going to use the public IP for DNS I'm just going to switch back to my terminal and I'm just going to hit enter over here uh it will ask are you sure you want to con connect so just type yes and here you can see you are just logged in into your AWS ec2 instance which is running onto AWS console and here you can see this is the user I'm just going to clear the screen um not let's wait let's verify some details over here so here this was the command which I have run after that I am able to successfully login into it and here these are the primary details these are the IP address where you can see 172 31453 I'm just going to copy go back to your AWS console and just find it so here you can see this is the private IP so just to make sure that we are just logged in into the correct ec2 instance so yeah we are logged in into correct dc2 instance and after that you can just verify a few of the documentation uh details like these are details which are available and this is the uban to user along with the uh IP address so I'm just going to clear it and here you can see and also a few more thing I just wanted to type you name r so that we can verify the kernel so this is the kernel of my uh uban 2 anyway uh so the idea was uh for this tutorial was to show you like how to launch an E2 instance and how to associate your public key and private key and how you can use the private key to to SSH into your ec2 instance and now you can see uh we are able to successfully access our ec2 instance and now you can just do the custom package installation whatever you want to perform with this virtual machine so that's up to you since now we have learned like how to launch an ec2 instance now let's uh terminate this particular instance and for that what I'm going to do I'm just going to type exit over here and now I am exit from the ec2 machine which is running remotely on AWS and now I am running I am onto my local uh system so I'm just going to run the ls command so here you can see this is the path of my local uh laptop where I'm working I'm just going to go back over here onto uh ec2 dashboard so click on ec2 over here and just refresh it here you can see the one stance running click on here click on this check box and then go to action uh instance State sorry and here you just need to click on terminate instance if you just do the stop instance then it is just going to stop or shut down that particular Linux machine but it is not going to destroy or delete that ec2 instance in case if you want to destroy it and if you don't want to use it further then I would recommend you to go with the terminate instance otherwise if you want to reuse this particular E2 instance then just click on stop so for the time being uh I have just created this instance for the demo purpose so I'm just going to click on terminate instance and click on terminate and it might take a couple of minute or so uh just refresh it click uh remove this filter and here you can see first it will shut down and after that it is going to terminate this particular instance so this was a very small uh intro session on ec2 instances in the upcoming chapter we will take a more Deep dive into the ec2 instances and what we can do with those ec2 instances when you're actually working in a company and what are the like precautions which you need to take and what are the practices which you need to follow when you are working with the ec2 instances if you have any question related to this chapter then please put down into the comment section I'll try to get back to you with the more detailed answer see you into the next chapter till then take care bye-bye
Info
Channel: Rahul Wagh
Views: 6,705
Rating: undefined out of 5
Keywords: AWS, AWS EC2, launch ec2, launch ec2 with ssh keys, ec2 private public key
Id: 2zeoNC4cdTA
Channel Id: undefined
Length: 16min 8sec (968 seconds)
Published: Mon Oct 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.