Step by Step Creation of an EC2 Instance in AWS and Access it via Putty & WinSCP
Last Updated on August 26, 2020 by Editorial Team
Author(s): Balakrishnakumar V
Cloud Computing
An EC2 instance is a virtual server (Just like our computer, but in the cloud) in Amazonβs Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure.
Letβs getΒ started.
- Under services, click EC2 present under the computeΒ section.
2. Click LaunchΒ Instance
3. Search for ubuntu-based instance, also click Free Tier only, to avoid incurring any charges and now we select Ubuntu server of 18.04 Version for running deep learning-based applications. You can also choose other OS such as windows etc. But here we stick to the ubuntu based server. Then clickΒ select
4. Select t2.micro instance, again to stay under free tier & it provides good performance for entry-level applications and click Next: Configure InstanceΒ Details.
5. Leave the defaults as it is, and if you wish to change any parameters feel free to doΒ it.
6. Next for storage, we leave the default 8 GB of space and make sure Delete on Termination is enabled( Disable it if you wish but not recommended) and click Next: addΒ Tags
7. Choose to add tags by creating a new Key & Value pair for easy identification of particular EC2 instances, in case you will be managing more EC2βs in the future and click Next: Configure SecurityΒ Groups
8. You can create either a new security group or use a previously created or default one. Here I created a new security group and provided access only to SSH-based connection via putty using the default port of SSHβββ22.
You can open other ports such as HTTP(80) / HTTPS(443) based on requirements. And click Review andΒ Launch
9. Make sure you verify all of the fields and then click on theΒ launch.
10. Now a pop-up window opens and now create a new key pair and download it by clicking the button Download KeyΒ Pair.
This will download aΒ .pem file, which is used as a security measure to access our created EC2 instance every time. Beware without this key pair (.pem) file you not will able to access into your server, so make sure to keep this file safe andΒ secure.
Avoid sharing your (.pem) file with others, because anyone can access your server with thisΒ file.
Now click on launch instance to finally launch ourΒ EC2.
Now Click View instance.
11. Add a name to identify your instance and in the descriptions tab, you have the IPV4 DNS & address to connect into your instance. Now let us use the downloaded (.pem) file and try to access the newly created EC2 instance.
12. There are many ways to connect and view our EC2 instance. Here I will demonstrate 2 methods of connecting to our EC2 instances.
I. UsingΒ Putty
Download the putty software here: https://www.putty.org/
IIΒ . UsingΒ WinSCP
II. Download WinSCP software here: https://winscp.net/eng/download.php
Using Putty
13. Now after installing the software of your choice, we have to convert the downloaded key file (.pem) β (.ppk) to access our instance using the two software listedΒ above
But nothing to worry, it can be done using the putty that we installed before.
On the windows start menu, type putty, and select puTTYgen.
14. Now click the load button and select the downloaded (.pem) file of yourΒ choice.
15. After loaded, click on save private key and a prompt opens and select yes to save it without a passphrase and no if you wish to have a passphrase. In our case, we selectΒ YES.
16. Now give it a new name and save the file with (.ppk) format and clickΒ ok.
17. Now we have successfully converted (.pem) to (.ppk)Β format.
18. Now letβs try to access our EC2 instance using putty with the new (*.ppk) file generated.
19. Select putty from the startΒ menu.
20. Now go back to AWS EC2 instance console and copy the public IP address and paste it in the putty configuration window.
21. Now after pasting the IP address, navigate to ssh category in the putty, and click Auth. Now click the Browse button in the tab, now select the (*.ppk file) we have converted and openΒ it.
22. Now a new command-line interface will open and in the prompt window, click yes (since we trust thisΒ network)
23. Now it asks for the username, so for our ubuntu instance, the username is ubuntu. Type and press enter. Now we have successfully logged into our instance.
Run the command: β sudo apt-get update β for the first time to update the ubuntu packages for security measures and new updates. Run this command occasionally to update yourΒ system.
Since AWS EC2 provides a virtual server, one of the way we can interact with it is via the command line. It will be a little bit intimidating for the first time since most of us are using the GUI based interface in ourΒ windows.
But believe me, itβs going to be awesome and also itβs veryΒ fast.
Using WinSCP
24. Connecting via WinSCP software is another way to connect into our instance and this option provides us a GUI based interface, so we feel like windows based options which we are already usedΒ to.
Now open WinSCP from your startΒ menu.
Now Click New session tab and then in the pop-up window click New Site, and then populate the field Host nameΒ : (your IP address of EC2) and username: ubuntu (incase of ubuntu based instance).
Then click the Advanced button in theΒ menu
25. Upon clicking the Advanced button, a new pop-up window opens, now select the SSH tab, and select the Authentication tab underΒ it.
Here add your (*.ppk) file under the private key file and finally clickΒ OK.
Now click the loginΒ button.
Click Yes (because we trust this network).
26. Success, now we can access the EC2 instance via WinSCP with a custom GUI interface.
Our home directory is /home/ubuntu/, now we see there any no files created in it. So let's add some files in it and then access it via ourΒ putty.
Now I created aΒ .txt file in the local computer and moving it into our EC2 instance.
Letβs do a simple Copy andΒ Paste.
27. Now letβs access this file via ourΒ putty.
Thatβs it, we just moved a file into EC2 and opened it. To exit the editor, follow the commands Insert -> Esc -> typeΒ :q! ->Β Enter.
28. Type Exit, to safely move out of our instance.
29. Finally, to avoid any additional charges, you can stop the EC2 instance when not in use and startΒ later.
Do not terminate the instance, as it gets deleted from your console. You can terminate it if you wish you donβt need it anymore. All the storage volume will be deleted together.
30. Thatβs so cool, you made it till the end and this is how we create an EC2 instance in AWS. Drop your comment if you face any problems in theΒ midway.
It is best practices to check the pricing of EC2 instances if you wish to play differently: https://aws.amazon.com/ec2/pricing/
And I will be posting articles related to Machine and Deep Learning and also their intersection with AWS Services.
Until then, see you nextΒ time.
Article By:
BALAKRISHNAKUMAR V
Co-FounderβββDeepScopy
Connect with me β LinkedIn, GitHub, Twitter,Β Medium
`
Visit us β DeepScopy
Connect with us β Twitter, LinkedIn, Medium
Step by Step Creation of an EC2 Instance in AWS and Access it via Putty & WinSCP was originally published in Towards AIβββMultidisciplinary Science Journal on Medium, where people are continuing the conversation by highlighting and responding to this story.
Published via Towards AI