Ex.
10 EC2 Instance Linux virtual machine launch and access using putty
application/SSH Client from any network/specified
network by private keypair
Step 1: Launch an EC2 Linux Instance
1. Login to AWS Management Console
○ Go to AWS Console
○ Navigate to EC2 service.
2. Launch an EC2 Instance
○ Click on Launch Instances.
○ Choose Amazon Linux 2 (or your preferred Linux AMI).
○ Select Instance Type (e.g., t2.micro for free-tier).
○ Click Next: Configure Instance Details.
3. Configure Network Settings
○ For Any Network (Public Access):
■ Ensure the instance is in a public VPC with an Internet Gateway.
■ Assign a public IP to the instance.
○ For Specified Network (Private Access):
■ Use a VPC and subnet without public IP.
■ Access via VPN, Bastion Host, or AWS Systems Manager Session
Manager.
4. Add a Security Group
○ For Any Network (Public Access):
■ Add Inbound Rule for SSH (port 22) from Anywhere (0.0.0.0/0).
■ ⚠️This allows global access, which is NOT secure.
○ For a Specified Network (Restricted Access):
■ Set Inbound Rule for SSH (port 22) to allow access only from a
specific IP or CIDR range.
■ Example:
■ Your office/home IP 203.0.113.0/32
■ Company network 10.0.0.0/16
5. Create & Download a Key Pair
○ Select "Create a new key pair" (or use an existing one).
○ Choose RSA and .pem format.
○ Download and save the .pem file securely.
6. Launch the Instance
○ Click Launch and wait for the instance to start.
Step 2: Convert .pem Key for PuTTY (Windows Users)
PuTTY does not support .pem files directly, so you need to convert it into a .ppk file.
1. Download & Open PuTTYgen
○ Download PuTTYgen if not installed.
○ Click Load and select the .pem file.
○ Click Save private key (ignore warning) Save as .ppk.
Step 3: Connect to EC2 using PuTTY
1. Open PuTTY
2. Enter Public IP of EC2 instance:
○ Find it under EC2 > Instances > Public IPv4 Address.
○ Example: 54.123.45.67
3. Load the Private Key
○ In PuTTY, navigate to SSH > Auth.
○ Click Browse and select the .ppk file.
4. Set Username
○ Under Connection > Data, enter ec2-user (Amazon Linux/RedHat).
○ Other OS default users:
■ Ubuntu: ubuntu
■ Debian: admin
■ CentOS: centos
5. Click Open → Accept the security alert → You are now connected! 🎉
Step 4: Connect to EC2 using SSH (Linux/macOS)
If using Linux/macOS, you can connect using the command line.
1. Open Terminal.
2. Navigate to the directory where .pem is stored.
Run the following command:
bash
CopyEdit
chmod 400 your-key.pem # Set correct permissions
ssh -i your-key.pem
[email protected] 3.
Optional: Configure Static IP (Elastic IP)
By default, the public IP changes if the instance stops. To assign a static IP:
1. Go to EC2 > Elastic IPs.
2. Click Allocate Elastic IP.
3. Associate it with your instance.