Contents [hide ]
What is EC2 in AWS?
How to launch Amazon Linux EC2 Instance?
How to Stop EC2 Instance?
How to Start EC2 Instance?
How to Delete/ Terminate EC2 Instance?
Different ways to connect to EC2 instance
i Using Command Prompt to connect EC2 instance
ii Using FileZilla to connect EC2 instance
iii Using PuTTY to connect EC2 instance
iv Using WinSCP to connect EC2 instance
v Using RDP client to connect EC2 instance
How to assign Elastic IP to EC2 instance?
How to deregister Elastic IP?
How to solve .pem file bad permissions issue?
How to generate .ppk file from .pem file?
How to upload a file from the local machine to the EC2 instance?
How to download a file from the EC2 instance to the local machine?
Important Points
What is EC2 in AWS?
Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud.
How to launch Amazon Linux EC2 Instance?
We need to follow below steps:
Step 1: Sign in AWS Account. Click on the EC2 icon under Recently visited services. If it is not visible search EC2 in the search bar. Then click on the EC2 icon.
Step 2: Click on Launch instance -> Launch instance Button.
Step 3: Choose any Machine. Here I choose Amazon Linux 2. Then click on the Select button.
Step 4: Select machine type. Here I choose t2.micro. Then click on Configure Instance Details button.
Step 5: In this screen If you want you can Configure Instance Details. Then click on Add Storage button.
Step 6: In this screen, you can change Volume Size and Volume Type as well as also Add New Volume. Then click on Add Tags button.
Step 7: In this screen, you can add Tag Name for adding tag name click on Add Tag button and enter tag name. Then click on Configure Security Group button.
Step 8: In this screen, you can Add Rule like allow Protocol and Port Number. Then click on the Review and Launch button.
Step 9: In the Review Instance Launch screen you can verify all details then click on the Launch button.
Step 10: In this screen, you can choose: Select an existing key pair or create a new key pair. If you did not create any key pair already or if you want to use new key pair then select Create a new key pair option. Give key pair name and click on Download Key pair button.
Step 11: If you want to use existing key pair then Choose an existing key pair option. Then click on the check box and then click on the Launch Instances button.
Step 12: In this screen, you can see Instances Launch Status. Click on Instance ID.
Step 13: In this screen, you can see created Instance.
How to Stop EC2 Instance?
Below Actions need to perform for stop, running ec2 instance.
Click on the Actions button -> Instance State -> Click on Stop Button
Click on the Yes, Stop button.
How to Start EC2 Instance?
Below Actions need to perform for start, stopped ec2 instance.
Click on the Actions button -> Instance State -> Click on Start Button
OR
Select ec2 instance -> Click on Instance state -> Click Start instance
Now instance will start.
How to Delete/ Terminate EC2 Instance?
Below Steps need to perform for the delete ec2 instance.
Step 1: Select ec2 instance.
Step 2: Click on Actions button -> Instance State -> Click on Terminate button
Step 3: Click on the Yes, Terminate button.
Step 4: Now, the ec2 instance terminates.
Different ways to connect to EC2 instance
- Using Command Prompt to connect EC2 instance
- Using FileZilla to connect EC2 instance
- Using PuTTY to connect EC2 instance
- Using WinSCP to connect EC2 instance
- Using RDP client to connect EC2 instance
Step 1: Click on Connect button.
Step 2: Click on the SSH Client tab and copy the selected command.
Step 3: Open a command prompt and go to the pem file location. Which is download/ selected at the time of ec2 instance launch time. Paste copied command here. Press enter key. If the message "Are you sure want to continue connecting" comes. Type Yes and press Enter key.
Step 4: If you are facing the below permission-related issue. Then you have to give proper permission to pem file. Here I am using the windows system them below steps need to be required related to permission.
Step 5: How to solve .pem file bad permissions issue?
Click Here for steps solve .pem file bad permissions issueStep 6: Now Repeat Step 3. [Copy ssh command in command prompt]
Step 7: Now ec2-instance is connected. Disconnect ec2-instance type “exit”. Press Enter key.
Step 1: Download and install FileZilla in your system if it is not already installed in the system. Here you have required .ppk for connecting ec2 instance using FileZilla. If you don't have .ppk file follow Step 2 otherwise skip it.
Step 2: How to generate .ppk file from .pem file?
Click Here for steps generate .ppk file from .pem fileStep 3: Open FileZilla. Then click on the Edit button. Click on the Settings button.
Step 4: Go to the left side mentioned path. Then click on Add key file… Button.
Step 5: Select the ppk file in your system location. Then click on Open Button.
Step 6: Now you can see the ppk file imported successfully. Click on Ok Button.
Step 7: Copy ec2 instance public IP address.
Step 8: Now put ec2 instance public IP address inside Host: Text Field. Ec2 instance user name inside Username: Text Field. 22 port number inside Port: Text Field. Click on the Quickconnect button. Click on the OK button.
Step 9: Now ec2 instance is connected.
Note: Before upload or download a file selects the proper destination path. Where file should be put.
Now you can upload the file in the ec2 instance. Right-click on the file then click on the Upload button.
You can download the file in the ec2 instance. Right-click on the file then click on the Download button.
Step 1: Download and install PuTTY in your system. If it is not already installed in the system. Here you have required .ppk for connecting ec2 instance using PuTTy. If you don't have .ppk file follow Step 2 otherwise skip it.
Step 2: How to generate .ppk file from .pem file?
Click Here for steps generate .ppk file from .pem file
Step 3: Open PuTTY. Select left side path location then click on the Browse button and select .ppk file from your system. Click on the Open button.
Step 4: Copy public IP address from ec2 instance.
Step 5: Select session in PuTTY, paste public IP address inside Host Name (or IP Address) text field. Port Number should be 22. The SSH check box should be checked. Then click on the Open button.
Step 6: Then give ec2 instance user name. Here current ec2 instance user name is “ec2-user”. Then press Enter key.
Step 7: Now ec2 instance is connected.
Step 1: Download and install WinSCP in your system if it is not already installed in the system.
Step 2: Open WinSCP. Then click on the Advanced… button.
Step 3: Go to the left side path. Then Browse the .ppk file under the Private key file:
Step 4: Select the .ppk file in your system location. Then click on Open Button. Click on OK Button.
Step 5: Copy ec2 instance public IP address.
Step 6: Now put ec2 instance public IP address inside Host Name: Text Field. Ec2 instance user name inside User name: Text Field. 22 port number inside Port number. Click on Login Button.
Step 7: Now ec2 instance is connected.
Step 1: Now I am using windows ec2 instance. Select ec2 instance. Click on Connect Button.
Step 2: Click on Get Password Button.
Step 3: Click on Choose File Button. Go to the .pem file location in your system and select the .pem file. Which is downloaded/ select at the time of launch Windows ec2 instance. Click on the Open button.
Step 4: Click on the Decrypt Password button.
Step 5: Now you can see the password on the below screen. Copy Password. Click on the Download Remote Desktop File button.
Step 6: Click on the downloaded file. Then click on Connect Button. Paste here copied password. Click on the OK button. Click on the Yes button.
Step 7: Now windows ec2 instance is connected.
How to assign Elastic IP to EC2 instance?
Step 1: In the below screen you can see selected ec2 instance is not associated with Elastic IPs.
Step 2: Go to the Elastic IPs tab. Click on Allocate new address button.
Step 3: I am selecting the Amazon Pool scope. Click on Allocate Button.
Step 4: Click on the Close button.
Step 5: Click on the Actions button. Click on the Associate Address button.
Step 6: Select ec2 instance. Click on the Associate button.
Step 7: Now you will see a success message. Click on the Close button.
Step 8: Now elastic IP address associated to ec2 instance. Click on Instance Id.
Step 9: Now you can see elastic IP is associated with IPv4 Public IP address.
How to deregister Elastic IP?
Step 1: Go to the Elastic IPs tab. Click on the Actions button -> Disassociate Address button.
Step 2: Click on Disassociate address button.
Step 3: Now elastic IP, disassociate from ec2 instance. You can see the below screen.
Step 4: Now finally Release elastic IP address. Go to the Elastic IPs tab. Click on the Actions button -> Click the Release addresses button.
Step 5: Click on the Release button.
Step 6: Now elastic IP address Release successfully also, removed from showing list.
How to solve .pem file bad permissions issue?
If you face the below issue while connecting ec2 instance using Windows System then the below steps need to follow:
Step 1: Go to the pem file location -> Right click on pem file -> Click on Properties button -> Click Security Button -> Click on Advanced Button
Step 2: Click on Add Button.
Step 3: Click on the Select a principal button.
Step 4: Inside Enter the object name to select, text field type “Administrator”. Click the Check Names button. Click on the Advanced… button.
Step 5: Click on Find Now button. Select your system user. Click the OK button.
Step 6: Now you can see the object name to select text field value, changed with your user name. Click on OK Button.
Step 7: Basic permissions Options. Check Full control. Click on the OK button.
Step 8: Click on Disable inheritance button. Click on Remove all inherited permissions from this object.
Step 9: Click on Apply -> Click on the OK button.
Step 10: Click on the OK button.
How to generate .ppk file from .pem file?
Step 1: Download and install PuTTYgen in your system. If it is not already installed in your system.
Step 2: Open PuTTYgen. Then click on Load Button.
Step 3: Then select the .pem file. Click on the Open button.
Step 4: Click on the OK button.
Step 5: Then click on Save private key button. Then click on the yes button
Step 6: Give file name. Then click on the Save button.
Step 7: Now .ppk file is available in your system.
How to upload a file from the local machine to the EC2 instance?
Syntex: scp -i Pem_File_Location Upload_File_Location EC2_USER@Public_IPv4_DNS : Destination_File_Location
Example: To upload a single file. Use the below command. Here I am going to upload only 1.txt file.
Example: To upload multiple files. Use the below command. Here I am going to upload all .txt extension files.
Example: To upload multiple files. Use the below command. Here I am going to upload all types of extension files (.txt, .docx etc).
How to download a file from the EC2 instance to the local machine?
Syntex: scp -i Pem_File_Location EC2_USER@Public_IPv4_DNS : Source_File_Location Destination_File_Location
Example: To download a single file. Use the below command. Here I am going to download only 1.txt file.
Example: To download multiple files. Use the below command. Here I am going to download all .txt extension files.
Example: To download multiple files. Use the below command. Here I am going to download all types of extension files (.txt, .docx etc).
Important Points:
1. This post showing the screenshot view may be different at the time of practical. If you follow the concept then definitely you will get the desired output.
2. If you are not using EC2 Instance then you should stop EC2 instance. Stopped ec2 instance will not charge you.
3. If there is an elastic IP address that is not associated with running the ec2 instance. Release it otherwise it will charge.
4. While launching EC2 instance, instance type selection should be based on requirement type.