Connect to your Linux instance using SSH
After you launch your instance, you can connect to it and use it the way that you'd use a computer sitting in front of you.
The following instructions explain how to connect to your instance using an SSH client. If you receive an error while attempting to connect to your instance, see Troubleshoot connecting to your instance. For more connection options, see Connect to your Linux instance.
Prerequisites
Before you connect to your Linux instance, complete the following prerequisites.
Check your instance status
After you launch an instance, it can take a few minutes for the instance to be ready so that you can connect to it. Check that your instance has passed its status checks. You can view this information in the Status check column on the Instances page.
Get the public DNS name and user name to connect to your instance
To find the public DNS name or IP address of your instance and the user name that you should use to connect to your instance, see Prerequisites for connecting to your instance.
Install an SSH client on your local computer as needed
Your local computer might have an SSH client installed by default. You can verify this by typing ssh at the command line. If your computer doesn't recognize the command, you can install an SSH client.
Recent versions of Windows Server 2019 and Windows 10 - OpenSSH is included as an installable component. For more information, see OpenSSH in Windows.
Earlier versions of Windows - Download and install OpenSSH. For more information, see Win32-OpenSSH.
Linux and macOS X - Download and install OpenSSH. For more information, see https://www.openssh.com.
Connect to your Linux instance using an SSH client
Use the following procedure to connect to your Linux instance using an SSH client. If you receive an error while attempting to connect to your instance, see Troubleshoot connecting to your instance.
To connect to your instance using SSH
In a terminal window, use the ssh command to connect to the instance. You specify the path and file name of the private key (.pem), the user name for your instance, and the public DNS name or IPv6 address for your instance. For more information about how to find the private key, the user name for your instance, and the DNS name or IPv6 address for an instance, see Locate the private key and set the permissions and Get information about your instance. To connect to your instance, use one of the following commands.
(Public DNS) To connect using your instance's public DNS name, enter the following command.
ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name
(IPv6) Alternatively, if your instance has an IPv6 address, to connect using your instance's IPv6 address, enter the following command.
ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-IPv6-address
You see a response like the following:
The authenticity of host 'ec2-198-51-100-1.compute-1.amazonaws.com (198-51-100-1)' can't be established.
ECDSA key fingerprint is l4UB/neBad9tvkgJf1QZWxheQmR59WgrgzEimCG6kZY.
Are you sure you want to continue connecting (yes/no)?
(Optional) Verify that the fingerprint in the security alert matches the fingerprint that you previously obtained in (Optional) Get the instance fingerprint. If these fingerprints don't match, someone might be attempting a "man-in-the-middle" attack. If they match, continue to the next step.
can't be established.
RSA key fingerprint is 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f.
Are you sure you want to continue connecting (yes/no)?
(Optional) You can optionally verify that the fingerprint in the security alert matches the instance fingerprint. For more information, see (Optional) Get the instance fingerprint.
Enter yes.