To connect to your Linux instance using an SSH client, follow these steps.
Syntax:
ssh -i /path/key-pair-name.pem instance-user-name@instance-public-dns-name
It doesn’t need to be in the same order, you can flip the params left to right.
ssh yourUserName@yourinstance.compute.amazonaws.com -i yourpemfile.pem
Example:
ssh root@ec2-19-192-191-190.eu-west-2.compute.amazonaws.com -i stg-instance.pem
Requirements:
- Check your instance status. It may take a few minutes for an instance to be prepared once you launch it so that you can connect to it. Verify that the instance’s status checks have been successful.
- Locate the private key and set the permissions. When you launch the instance, Amazon often provides a.pem file that contains the SSH key.
- Get the public DNS name and user name to connect to your instance. The IP address or instance name given to your EC2 instance must be known. Keep in mind the username that was issued by the Linux distribution you launched.
- Install an SSH client on your local computer as needed. An SSH client might already be set up on your local machine. By entering ssh at the command line, you may confirm this. Install an SSH client if your machine doesn’t understand the command.