EC2 - jsonamit/aws GitHub Wiki
To connect to an AWS EC2 instance using a .pem file (private key file), you'll typically use SSH (Secure Shell) from a Unix-like terminal (Linux, macOS) or a tool like PuTTY on Windows. Here’s a step-by-step guide for each platform:
Step 1 : Open a Terminal
Step 2 : Change Permissions of the .pem File
chmod 400 path/to/your-key-file.pem
Step 3 : Connect to the EC2 Instance
ssh -i path/to/your-key-file.pem username@ec2-public-ip
ssh -i /path/to/your-key-file.pem [email protected]
Note: The username varies depending on the AMI you used
- For Amazon Linux or Amazon Linux 2: ec2-user
- For Ubuntu: ubuntu
- For CentOS: centos
- For Debian: admin or root
- For RHEL: ec2-user or root
To run an HTML file on your AWS EC2 instance, you need to set up a web server. Here's how you can do it using Apache on a Linux-based EC2 instance (e.g., Amazon Linux, Ubuntu).
For Amazon Linux
sudo yum update -y
For Ubuntu:
sudo apt update
Install Apache Web Server
- For Amazon Linux:
sudo yum install httpd -y
- For Ubuntu:
sudo apt install apache2 -y
Verify Apache Installation
- Check if Apache is running by accessing your EC2 instance's public IP address in a web browser. You should see the Apache test page.
Upload Your HTML File
- You need to place your HTML file in the web server's root directory.
- For Amazon Linux, the default directory is /var/www/html/.
Access Your HTML File
http://your-ec2-public-ip/your-file.html