Amazon Virtual Private Cloud in AWS (Amazon Web Services) (PART -5)

Share via:
Dear Readers,

In this article,we will see  connect database server through bastian server and install required packages.

for that we have to follow below steps.

  1. Copy Database Server pem key to bastian server with the help of WinSCP tool.
  2. Download and Install WinSCP tool.
  3. Convert BastionServer keypair “bastionserver.pem”  to “bastionserver.ppk” by using puttygen.
  4. Connect to Bastion Server through putty.
  5. copy Database Server keypair “dbserver.pem” to BastionServer home location “/home/ec2-user”.
  6. Connect to DBServer through BastionServer.
  7. Create NAT Gateway and Provide Internet to DBServer.
  8. Modify existing default Route Table.
  9. Connect to NAT Gateway and Private Subnet.
  10. Install required packages in database server.

Please check the below link for part-4

Amazon Virtual Private Cloud in AWS (Amazon Web Services) (PART – 4)

If you want to connect to database server,the database server pem file should be in bastian server.

we can’t copy pem file directly to the bastian server for that we have to use third party Tool called WinSCP.

we download WinSCP and install on the base machine then we can copy pem file.

Download WinSCP Tool

As a first step we need download the WInscp by using below link.

https://winscp.net/eng/download.php

The WinSCP tool has been downloaded successfully.

Install WinSCP Tool

Go to physical location and double click on WinSCP software.

Click on Accept.

Choose Typical installation and click on Next.

Choose User interface style “Commander” and click on Next.

Click on Install.

It’s loading wait till complete.

Click on Finish.

Convert BastionServer keypair bastionserver.pem to bastionserver.ppk by using puttygen

Go to physical location and click on puttygen tool.

You need to click on the Load button.

Browse and select the keypair file (bastionserver.pem).

Click on Save private key and click on yes.

Save  with name of bastionserver.

The file has been saved in physical  location with the name of bastionserver (format is PPK).

Connect to Bastion Server through putty

Select bastian server and click on connect.

In order to connect to your Linux virtual machine instance, you will need a third-party tool like putty.

Copy public IP for connect your instance through putty.

Go to physical location and you need to open Putty.exe then enter Bastion IP which was copied earlier from Bastion server.

Go to connection,

At the left side menu then select “SSH” and then select “Auth”. You need to click on the browse button to select the My bastionserver.ppk file that we created recently.

Click on open.

Ignore warnings and click on yes.

Once you connect, you will successfully see the Linux Server prompt.

copy Bastion Server Public IP

Open WinSCP and enter the hostname (BastionServer public) and click on Advanced.

 

Go to connection,

At the left side menu then select “SSH” and then select “Auth”. You need to click on the browse button to select the My bastionserver.ppk file that we created recently.

Click on ok.

Click on Login.

 

Ignore warnings and click on yes.

Specify username for Bastion Server “ec2-user” and click on ok.

Copy Database Server keypair “dbserver.pem” to BastionServer home location “/home/ec2-user”

We can see at left side is base laptop.

Right-side is BastionServer home location “/home/ec2-user/”.

Now we need to copy DBServer keypair “dbserver.pem” to BastionServer home location “/home/ec2-user”.

Go to keypair location and select the keypair “dbserver.pem” then drag and drop to BastionServer home location.

The keypair has been copied successfully to bastionserver home location.

Go Linux terminal and check the keypair.

Connect to DBServer through BastionServer

Select DBServer and click on connect.

Copy DBServer private IP and paste in BastionServer.

Go to BastionServer Linux terminal.

Switch to root user and enter DBServer private ip  “ssh -i “dbserver.pem” ec2-user@192.168.2.85”

Install updates in the DBServer

Switch to Root user and type update command

Note

we can see error “The updates are not installed because we don’t have any internet”

We need internet to install the updates in the database server.

we need to make internet connection through secure way by using NAT.

Create NAT Gateway and Provide Internet to DBServer

Go to Services, under the Networking & Content Delivery click VPC service to open.

Go to NAT Gateways and click on Create NAT Gateway.

Choose subnet “subnet 1 (pubic subnet)

Note

We create the NAT Gateway in the public subnet that’s why we need to select public subnet only.

To create New Elastic IP click on Create New EIP.

The Elastic IP has created successful and click on Create a NAT Gateway.

The NAT Gateway has been created and click on Close.

We can see NAT Gateway which was created earlier.

Connect Root Table “NATInternet-RT”  to subnet 2 “192.168.2.0/24  – ap-south-1b (subnet-2) – (Private Subnet)

Go to Route Tables and select Default route table which is connected your VPC and give name “NATIntenet-RT”.

Select Root table “NATInternet-RT” and go to subnet Associations then click on Edit subnet associations.

Checked subnet 1  ID “192.168.2.0/24  – ap-south-1b (subnet-2)” and click on Save.

We can see the route table has been connected to subnet 1 “192.168.2.0/24  – ap-south-1b (subnet-2) – (Private Subnet).

Connect Root Table “NATInternet-RT”  to NAT Internet Gateway “NATGW-ktexperts”

Go to Routes and click on Edit Routes.

Click on Add route.

Choose Internet Gateway option in the Target.

Select your Internet Gateway “NATGW-ktexperts”

Specify Destination with “0.0.0.0/0” and Target then click on save routes.

Note

Wherever you want internet you must choose IP 0.0.0.0/0.

We can message like Routes successfully edited then click on close.

The route table has been connected to your Internet Gateway “NATGW-ktexperts” successfully.

Go to Bastion Server linux terminal and connect to DBServer and install updates

Switch to root user 

Verify Database pem file 

Connect to Database Server

Switch to root user 

Install Server Updates

We are successfully connected to the database server and also getting internet with the help of NAT Gateway.

 

Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates

KTEXPERTS is always active on below social media platforms.

Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform

Share via:
Note: Please test scripts in Non Prod before trying in Production.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

Add Comment