SSH into your EC2 instances

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 usi…


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.
    Instance details

  • 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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » SSH into your EC2 instances." Ajit Singh | Sciencx - Wednesday June 16, 2021, https://www.scien.cx/2021/06/16/ssh-into-your-ec2-instances/
HARVARD
Ajit Singh | Sciencx Wednesday June 16, 2021 » SSH into your EC2 instances., viewed ,<https://www.scien.cx/2021/06/16/ssh-into-your-ec2-instances/>
VANCOUVER
Ajit Singh | Sciencx - » SSH into your EC2 instances. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/16/ssh-into-your-ec2-instances/
CHICAGO
" » SSH into your EC2 instances." Ajit Singh | Sciencx - Accessed . https://www.scien.cx/2021/06/16/ssh-into-your-ec2-instances/
IEEE
" » SSH into your EC2 instances." Ajit Singh | Sciencx [Online]. Available: https://www.scien.cx/2021/06/16/ssh-into-your-ec2-instances/. [Accessed: ]
rf:citation
» SSH into your EC2 instances | Ajit Singh | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.