1The Changing Public IP
A common beginner mistake is hardcoding an EC2 instance's Public IP into an application, only to have the app break when the instance is stopped and started. Always use DNS names or Elastic IPs for production workloads.
2Cryptography over Passwords
AWS strongly discourages password-based logins for Linux. Asymmetric cryptography (Key Pairs) is mathematically much harder to brute-force than any password. Keep your .pem file safe; if you lose it, you might lose access to the instance.
3Step-by-Step Breakdown
IP Addresses. Every EC2 instance gets an IP address to communicate. There are two main types: Public and Private.
Private IPs. A Private IP is assigned when the instance launches and stays with it until termination. It is used for communication within the VPC.
Public IPs. A Public IP allows the instance to be reached from the internet. However, if you stop and start the instance, the Public IP changes!
Elastic IPs (EIP). If you need a permanent Public IP that survives restarts, you allocate an Elastic IP and associate it with your instance.
SSH. Secure Shell (SSH) is the protocol used to securely log into Linux instances over the network.
IP Check. Which type of IP address changes when you stop and start an EC2 instance?
- →Private IP
- →Elastic IP
- →Default Public IP
Key Pairs. AWS uses public-key cryptography. AWS stores the Public Key on the instance, and you keep the Private Key (.pem or .ppk file).
Key Permissions. On Linux/Mac, SSH requires your private key file to have strict permissions, otherwise it will reject the connection.
EC2 Instance Connect. If you lose your key or don't want to manage them, AWS offers EC2 Instance Connect to SSH directly from the browser.
Completion. You can now connect to your servers securely.
