To connect to an Amazon EC2 instance from an Ubuntu machine, you can use the Secure Shell (SSH) protocol. Here are the steps:
Open a terminal window on your Ubuntu machine.
Locate the private key file that you specified when you launched the EC2 instance. This file will have a ".pem" file extension and is required to establish the SSH connection.
Change the permissions of the private key file to be read-only for the owner. This is done to prevent unauthorized access to the file.
Connect to the EC2 instance using the following command, replacing username with the appropriate username for the instance, and instance_ip_address with the public IP address of the instance:
You should now be logged in to your EC2 instance, and you can run commands and manage your instance from the terminal window on your Ubuntu machine.
Note: The default username for an EC2 instance varies based on the operating system being used. For example, for an Ubuntu instance, the default username is "ubuntu".