To Connect with your ec2 instance from your terminal , you need
- ssh installed on your machine
- pem (private key of ec2 instance) for secure login purpose.
- internet connection.
1 Install ssh to your local machine if previously not installed
sudo apt-get install openssh-server
2 In a command line shell, change directories to the location of the private key file that you created when you launched the instance.
3 Use the chmod command to make sure your private key file isn’t publicly viewable. For example, if the name of your private key file is
my-key-pair.pem, use the following command:
chmod 400 /
path/my-key-pair.pem 4 Use the ssh command to connect to the instance. You'll specify the private key (
.pem) file anduser_name@public_dns_name. For Amazon Linux, the user name is
ec2-user. For RHEL5, the user name is either
ec2-user. For Ubuntu, the user name is
ubuntu. For Fedora, the user name is either
ec2-user. For SUSE Linux, the user name is either
ec2-user. Otherwise, if
rootdon't work, check with your AMI provider.
ssh -i /
- (Optional) Verify that the fingerprint in the security alert matches the fingerprint that you obtained in step 1. If these fingerprints don’t match, someone might be attempting a “man-in-the-middle” attack. If they match, continue to the next step.
yes.You’ll see a response like the following.
Warning: Permanently added 'ec2-198-51-100-1.compute-1.amazonaws.com' (RSA) to the list of known hosts.