Setting up AWS EC2 with Ubuntu, Docker, and a Public IP
Follow these steps to quickly set up a basic server environment on Amazon Cloud (AWS).
Step 1: Log in to AWS Console
- Visit https://console.aws.amazon.com
- Log in using your AWS account credentials.
Step 2: Create an EC2 Instance
- From the AWS console, search for and select EC2.
- In the EC2 Dashboard, click Instances → Launch instances.
Step 3: Select Ubuntu Server
Step 4: Configure Security Settings
- Under Network settings, select Create security group.
- Ensure that at least the following ports are allowed:
- SSH (22) for secure access to your server.
- Add custom rules if needed, for example:
- HTTP (80)
- HTTPS (443)
- Click Launch instance.
Step 5: Connect to Your Instance
- After your instance launches, click on its name to see details.
- Locate the Public IPv4 address; this is your public IP address.
Step 6: Access Your Instance via SSH
- Open your terminal or command prompt.
- Connect using SSH (replace your-key.pem with the path to your downloaded AWS key file, and public-ip-address with your actual public IP):
chmod 400 your-key.pem
ssh -i your-key.pem ubuntu@public-ip-address
Step 7: Install Docker on Ubuntu
Follow Ubuntu | Docker Docs
You’re all set!
You now have:
- Ubuntu Server 22.04 running on AWS
- Docker installed
- A public IP address to access your server remotely
Secure Base64 Encoding via Linux Console
Step 1: Open your Linux terminal.
Step 2: Execute the following command (replace api_key and secret_key with your real keys):
echo -n "api_key:secret_key" | base64
Example:
If your keys are:
- API Key: abc123
- Secret Key: xyz789
Then run:
echo -n "abc123:xyz789" | base64
Output will look like:
YWJjMTIzOnh5ejc4OQ==
How it works securely:
- echo -n prevents adding a newline at the end of the text, which ensures correct encoding.
- base64 is a built-in utility that encodes the data right on your system without internet exposure.
You can then safely use this encoded string as your Basic Auth token: