點燈坊

失くすものさえない今が強くなるチャンスよ

Running Amazon Linux 2 on AWS EC2

Sam Xiao's Avatar 2021-11-13

We can run Linux server on AWS EC2 with public IP address.

Version

Linux Kernel 4.14

EC2

ec2000

  • Instances : select instances on the left menu
  • Launch Instances : build new Linux server

Amazon Linux 2

ec2001

  • Free tier only : select Free tier only to show only free images on the left
  • Amazon Linux 2 AMI : build new Linux server by Amazon Linux 2 AMI

Instance Type

ec2002

  • Select t2.micro for free
  • Click Review and Launch to accept default configuration and launch server directly

Review Instance Launch

ec2003

  • We are warned that default security group may be accessible from any IP address. For better security concerns, it would be better to only allow access from known IP address only
  • If we want to use other port (e.g. HTTP (80)), we have to open that port manually

Key Pair

ec2004

  • Select existing key pair
  • Click Launch Instances to run server

Launch Status

ec2005

Run Linux server successfully.

Instance Summary

ec2006

We can get public IP of Linux server on Public IPv4 address section.

SSH

$ ssh -i MyEC2.pem ec2-user@52.199.158.189

Use SSH to connect to Linux server :

  • -i : specify the location of pem
  • ec2user : the user for Amazon Linux 2
  • @ : public IP address of Linux server

ec2007

Type yes if we connect to Linux server first time.

Conclusion

  • We may encounter SSH connection error if we just use downloaded pem, try chmod 400 myEC2.pem to change permission

Reference

AWS, Launch an instance using the Launch Insance Wizard