Preliminary steps in setting up your Ubuntu Linux in AWS
- Launch an instance.

2. I will use the Ubuntu 24.04 LTS server free tier here. By the way, AWS gives 750 free hours for new users.

3. Choose instance type, create a key pair and set your network

- For instance type I chose t2.micro
- For Keypair, I generate public and private key pairs for SSH authentication. I already generated the blog-grace-keypair previously. It then prompts me to download the
.pemprivate key file which you will use to connect to your Ubuntu Linux through SSH. By the way, the Ubuntu Linux has a public key stored inside which allows you to connect to the server using your private key.

- Set your network. I already created a VPC with the security group. Make sure to allow ports 80 and 443 to expose the web connection publicly. You can just allow 443 and set up a certificate for a more secure connection. I already allowed HTTP, HTTPS and SSH connections in the security group.

- The storage for this will be 8 GiB gp3
4. Launch the instance
5. Attach a public IP(elastic IP) to it so you can access it remotely.

6. Allocate elastic IP from Amazon.

7. Now that you have elastic IP. Associate it.


8. Associate it to your new instance. Check the name of the instance and the IP address and then associate it with the public IP


9. To connect to the ubuntu server:
- If you are using MAC, connect to the terminus, then access the server using the public IP. And then use the saved blog-grace-keypair.pem certificate to connect.

- In the address, put the public IP. In the username, I didn't create a username so the default will be Ubuntu. Then for the password, our .pem key will serve as the authentication method instead of a password. Click the
+Key, Certificate, FIDO2. A drop down will appear and then choose Key (not the Certificate or FIDO2)

10. Now you are already connected to the server's SSH connection using your public and private key using Ubuntu as your username.
11. Now if you want to use your username to connect. Create a username
System information as of Sun Apr 6 18:20:24 UTC 2025
System load: 0.0 Processes: 113
Usage of /: 29.8% of 6.71GB Users logged in: 1
Memory usage: 22% IPv4 address for enX0: 172.31.2.79
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
60 updates can be applied immediately.
34 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
Last login: Sun Apr 6 18:13:04 2025 from 142.114.94.144
ubuntu@ip-172-31-2-79:~$ sudo adduser grace
info: Adding user `grace' ...
info: Selecting UID/GID from range 1000 to 59999 ...
info: Adding new group `grace' (1001) ...
info: Adding new user `grace' (1001) with group `grace (1001)' ...
info: Creating home directory `/home/grace' ...
info: Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for grace
Enter the new value, or press ENTER for the default
Full Name []: Grace
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] Y
info: Adding new user `grace' to supplemental / extra groups `users' ...
info: Adding user `grace' to group `users' ...
ubuntu@ip-172-31-2-79:~$
12. Once you create a username, you can create a keypair in either your linux machine, AWS or your local host. I created my keypair in Termius of MA
13. Create a public key from your .pem
ssh-keygen -y -f blog-grace-keypair.pem > blog-grace-keypair.pub
Add the .pem key in the Termius of MAC

14. Copy the private key in grace-new-blog-key.pem of your instance

15. Change the permission to rw----(600). It means only you can access your private key.
grace@ip-172-31-2-79:~$ chmod 600 grace-new-blog-key.pem
grace@ip-172-31-2-79:~$ ls -al
total 44
drwxr-x--- 4 ubuntu ubuntu 4096 Apr 6 19:53 .
drwxr-xr-x 4 root root 4096 Apr 6 18:20 ..
-rw------- 1 ubuntu ubuntu 246 Apr 6 19:21 .bash_history
-rw-r--r-- 1 ubuntu ubuntu 220 Mar 31 2024 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Mar 31 2024 .bashrc
drwx------ 2 ubuntu ubuntu 4096 Apr 6 17:43 .cache
-rw-r--r-- 1 ubuntu ubuntu 807 Mar 31 2024 .profile
drwx------ 2 ubuntu ubuntu 4096 Apr 6 19:40 .ssh
-rw-r--r-- 1 ubuntu ubuntu 0 Apr 6 17:45 .sudo_as_admin_successful
-rw------- 1 ubuntu ubuntu 7967 Apr 6 19:53 .viminfo
-rw------- 1 ubuntu ubuntu 420 Apr 6 19:40 grace-new-blog-key.pem
16. In your home directory (/home/grace/.ssh), add the public key
grace@ip-172-31-2-79:~$
grace@ip-172-31-2-79:~$ ls -al
total 40
drwxr-x--- 4 grace grace 4096 Apr 6 19:46 .
drwxr-xr-x 4 root root 4096 Apr 6 18:20 ..
-rw------- 1 grace grace 263 Apr 6 19:46 .bash_history
-rw-r--r-- 1 grace grace 220 Apr 6 18:20 .bash_logout
-rw-r--r-- 1 grace grace 3771 Apr 6 18:20 .bashrc
drwx------ 2 grace grace 4096 Apr 6 19:46 .cache
-rw-r--r-- 1 grace grace 807 Apr 6 18:20 .profile
drwxrwxr-x 2 grace grace 4096 Apr 6 19:46 .ssh
-rw------- 1 grace grace 1206 Apr 6 19:45 .viminfo
-rw------- 1 grace grace 419 Apr 6 19:45 grace-new-blog-key.pem
grace@ip-172-31-2-79:~$ cd .ssh/
grace@ip-172-31-2-79:~/.ssh$ ls
authorized_keys known_hosts known_hosts.old
grace@ip-172-31-2-79:~/.ssh$
17. Under /home/grace/.ssh, modify the authorized keys using vim/nano. Using nano authorized_keys, paste the public key you generated from your local machine. After that execute Ctrl O, then after that CTRL X to Exit

18. After that, execute ssh -i grace-new-blog-key.pem localhost
grace@ip-172-31-2-79:~$ ssh -i grace-new-blog-key.pem localhost
The authenticity of host 'localhost (127.0.0.1)' can't be established.
ED25519 key fingerprint is SHA256:cCAqv0RZAFyl8va7kZ/m13+LWZmFS7bBCFciEzcrtsw.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-1024-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Sun Apr 6 19:46:20 UTC 2025
System load: 0.08 Processes: 122
Usage of /: 31.2% of 6.71GB Users logged in: 1
Memory usage: 23% IPv4 address for enX0: 172.31.2.79
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
60 updates can be applied immediately.
34 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
grace@ip-172-31-2-79:~$ 19. After that you can now connect via SSH using Termius.
No Comments