點燈坊

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

Running Ubuntu on AWS EC2

Sam Xiao's Avatar 2021-11-14

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

Version

Ubuntu 20.04

EC2

ubuntu000

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

Ubuntu

ubuntu001

  • Free tier only : select Free tier only to show only free images on the left
  • Ubuntu Server 20.04 LTS : build new Linux Server by Ubuntu Server 20.04 LTS

Instance Type

ubuntu002

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

Review Instance Launch

ubuntu003

  • 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

ubuntu004

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

Launch Status

ubuntu005

Run Linux server successfully.

Instance Summary

ubuntu006

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

SSH

$ ssh -i MyEC2.pem ubuntu@18.176.57.41

Use SSH to connect to Linux server :

  • -i : specify the location of pem
  • ubuntu : the user for Ubuntu server
  • @ : public IP address of Ubuntu server

ubuntu007

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