Convert AWS Private Key (.pem) to PuTTY Private Key File (.ppk)
1. Launch PuTTYgen application from Start menu
2. Ensure that the Parameters are set the following values
3. Load the private key that for the instance that was generated by Amazon and Click OK
4. Click OK om the following dialog box
5. Now click on Save private key option on PuTTYgen
I did not add a passphrase to my private key file. Add a passphrase to the private key if you deem necessary. A save dialog box is shown. Enter an appropriate name, and save the file. The file is saved in .ppk format. This can be used with PuTTY to ssh into the EC2 instance
Connecting to your Linux instance using PuTTY
1. Start PuTTY from the Start Menu
2. In the left nav, click on Session
NOTE - For Amazon Linux 2 or Amazon Linux AMI, the username is ec2-user. Click here for more information.
2.1. Configure the connection details
Host Name: username@public_dns_name
2.2. (Optional) Configure keepalives. Click on Connection, and set the value as needed
2.3. Expand, SSH and select Auth. Click on the Browser button and navigate to the location where the private key generated by PuTTY, and click Open
Now click Open on the PuTTY Configuration window
2.4. There is a security alert. If you trust the fingerprint (which I do), click Yes
If everything is done right, the connection should be successful, and the following terminal window will be displayed.
Running a Web server
Now that SSH connection has been established, we will move on to updating the OS, and installing packages necessary for running a web server.
1. Type the following command in the terminal window -
sudo yum update -y
This will run all the necessary updates for your OS.
2. To install Apache on the instance, type the following -
sudo yum install httpd -y
At this point, the EC2 instance is capable of being an app server that can serve web pages on Apache.
3. Access the html directory in the web server directory by typing the following -
cd /var/www/html
Anything that lives in this directory will be accessible over port 80. In other words, this the directory out of which your website will be served.
4. Now, we will add an index.html to this directory using nono text editor. Type the following -
sudo nano index.html
This will open the text editor and allow you to add contents to index.html. Type the contents as shown.
Now, press Ctrl + X and press Y to save the file, and press Enter to save the file as index.html. Ensure that the file exists by running the ls command.
5. Start the service by typing -
sudo service httpd start
6. Now access the public ip address of the instance through the browser, and you should see the following -
Credit goes to AWS Certified Solutions Architect - Associate 2019 on udemy along with some tutorials I found. If you found this post helpful, be sure to thank the folks at CloudGuru.
No comments:
Post a Comment