This content originally appeared on DEV Community and was authored by Ajit Singh
What is ssh?
SSH is a remote management protocol through which you connect to your remote servers and modify them. This allows you to access your remote servers securely.
So let us see how we can connect with our EC2 instances securely using SSH
First see what your public IP address is from your ec2-instance.
After that if you are a Linux or Mac user open your terminal and run the following command ssh username@public-ip for me the public IP is 13.233.33.232 and default ec2 user is
ec2-user
so the final command becomes
ssh ec2-user@13.233.33.232
- Once you run it you will get the following message
The authenticity of host '13.233.33.232 (13.233.33.232)' can't be established.
ECDSA key fingerprint is SHA256:BudJr8YMxFu8ylCGragb1BfW04/VI6+hX017siHF19w.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Type yes and agree to it. After this you will get a message like this
Warning: Permanently added '13.233.33.232' (ECDSA) to the list of known hosts.
ec2-user@13.233.33.232: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
It's still not working but that is a good thing because if this allows us to ssh then anyone can ssh into our EC2 instance if he knows our public IP.
- In the last exercise we downloaded a pem file while creating our EC2 instance we need to use that pem file to login into out EC2 instance. to use that we run ssh -i path-to-file username@public-ip
ssh -i EC2test.pem ec2-user@13.233.33.232
It will still not allow you to signin and because permissions are to open. This is because right now our EC2 test.pem file permissions 0644 which allows any user to write on it. EC2 is complaining that even the root user should have read only permission so that no one can change our key file.
This can be easily resolved just do
chmod 400 EC2test.pem
- Which resolves the permissions issue now run the above command again.
ssh -i EC2test.pem ec2-user@13.233.33.232
- Now you will be logged into your ec2 instance.
This is it for how to remote access to your ec2 instance. In the next article in the series we will study more about the different EC2 instances and there advantages.
This content originally appeared on DEV Community and was authored by Ajit Singh
Ajit Singh | Sciencx (2021-06-16T06:36:22+00:00) SSH into your EC2 instances. Retrieved from https://www.scien.cx/2021/06/16/ssh-into-your-ec2-instances/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.