Connect EC2 instances from AWS CloudShell
You can connect AWS instaces from your computer via ssh. But if you are away from your computer, there is a good option: AWS CloudShell.
There are some basic steps to connect your EC2 instances from AWS CloudShell:
Firstly, you must be able to access the EC2 key pair. Because the key can only be retrieved at the time you create the keypair (via EC2 web management console or via API commandline). So you have to save the private key somewhere and be able to retrieve it at work in order to connect to the instance via SSH, since keypairs’ public keys are automatically installed on EC2 servers when you launch them.
In your EC2 Dashboard, you will see the Instances section. You can list all of your instances there. Select the instance that you want to connect and click the Connect button on the top right.
Click on the SSH client tab and you will see an example command. We will use this command later.
Now, let’s go to CloudShell. You can see the CloudShell logo anywhere on the AWS website.
We need key pair now. Upload your key on the Actions menu.
When uploading finished, type ls command to see the key.
Before connect command, we need to change permission of our pem file.
chmod 400 mlops_last_key.pem
Finallt, type connect command.
ssh -i "mlops_last_key.pem" ubuntu@ec2-54-164-150-236.compute-1.amazonaws.com
We logged in our EC2 instance from AWS CloudShell.