# 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****

- <span style="white-space: pre-wrap;">Visit </span>[https://console.aws.amazon.com](https://console.aws.amazon.com)<span style="white-space: pre-wrap;"></span>
- Log in using your AWS account credentials.

****Step 2: Create an EC2 Instance****

- <span style="white-space: pre-wrap;">From the AWS console, search for and select </span>****EC2****.
- <span style="white-space: pre-wrap;">In the EC2 Dashboard, click </span>****Instances****<span style="white-space: pre-wrap;"> → </span>****Launch instances****.

****Step 3: Select Ubuntu Server****

- <span style="white-space: pre-wrap;">Under </span>****Name and tags****, give your server a recognizable name (e.g., "MyUbuntuServer").
- <span style="white-space: pre-wrap;">Under </span>****Application and OS Images (Amazon Machine Image)****<span style="white-space: pre-wrap;">, select </span>****Ubuntu Server 22.04 LTS****. (or 24.04 LTS)
- Leave other settings at default unless instructed otherwise.

****Step 4: Configure Security Settings****

- <span style="white-space: pre-wrap;">Under </span>****Network settings****<span style="white-space: pre-wrap;">, select </span>****Create security group****.
- Ensure that at least the following ports are allowed:
- - ****SSH (22)****<span style="white-space: pre-wrap;"> for secure access to your server.</span>
    - Add custom rules if needed, for example:
    - - HTTP (80)
        - HTTPS (443)
- <span style="white-space: pre-wrap;">Click </span>****Launch instance****.

****Step 5: Connect to Your Instance****

- After your instance launches, click on its name to see details.
- <span style="white-space: pre-wrap;">Locate the </span>****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****

<span style="white-space: pre-wrap;">Follow </span>[Ubuntu | Docker Docs](https://docs.docker.com/engine/install/ubuntu/)<span style="white-space: pre-wrap;"></span>

****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

<span style="white-space: pre-wrap;"></span>

---

****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:

Authorization: Basic YWJjMTIzOnh5ejc4OQ==

<span style="white-space: pre-wrap;"></span>