Skip to content

Latest commit

 

History

History
39 lines (20 loc) · 2.66 KB

key-pair-and-ssh-connection.md

File metadata and controls

39 lines (20 loc) · 2.66 KB

Key Pair & SSH Connection

Key Pairs

Security should always be one of our first concerns while working in a cloud environment. After setting related configs we should safely connect to our EC2 instances and web services. Creating key pair is the first step of this process. After creating key pairs. Key pairs include public and private keys that give the ability to identify whether the connection is secure and trustworthy. For example thanks to key pairs, Linux users are able to connect the instances from their local to EC2 instances with SSH clients. It is easily can be created and downloaded by using AWS Management Console. But Keep it private!!!

Note:** For users with Linux, Mac and Windows>10 download the .pem**** extension file.** Download .ppk** extension key pairs file for Windows<10 users.**

It can be created through path EC2> Key pairs > Create key pair

Create Key Pair

After pressing Create key pair it will create and download the file automatically. Then in your file system put the downloaded file in any folder that you want.

SSH Connection

After creating a key pair process, now we are ready to connect to our instances via SSH Client. Also don't forget to add this key pair and allow SSH connection on the instance that we want to connect. Otherwise, you are not able to connect to the instance.

First, go to the folder where the downloaded key pairs are located.

Then change the read write execute roles using the chmod and set to it 400 otherwise you may get the following error related to file permissions.

SSH Error

Then add the following line to the command line and execute.

chmod 0400 filename.pem // My file is testkeypair yours can be different

After changing the key pair files roles we are ready to connect the instance. But before the connection, we will use the ec2-user user that was given to us by default after the instance creation. Also the IP address is the Public IP that is automatically set to instance. You could check it from the console.

If you see this kind of log yes you connected to an EC2 instance that you create 🎉🚀😎