We can run Linux server on AWS EC2 with public IP address.
Version
Linux Kernel 4.14
EC2
Instances
: selectinstances
on the left menuLaunch Instances
: build new Linux server
Amazon Linux 2
Free tier only
: selectFree tier only
to show only free images on the leftAmazon Linux 2 AMI
: build new Linux server byAmazon Linux 2 AMI
Instance Type
- Select
t2.micro
for free - Click
Review and Launch
to accept default configuration and launch server directly
Review Instance Launch
- 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
- Select existing key pair
- Click
Launch Instances
to run server
Launch Status
Run Linux server successfully.
Instance Summary
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 pemec2user
: the user for Amazon Linux 2@
: public IP address of Linux server
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