Author - Daniels Kenneth In category - Software development Publish time - 13 October 2022

Since then, we have published 360 articles, 49 podcast episodes, and 47 videos. It’s all free and means a lot of work in our spare time. We enjoy sharing our AWS knowledge with you. I hope you enjoy this approach to connect to your EC2 instances using SSH as much as I do.

ssh ec2 instance

All you need to do is type ssh followed by an EC2 instance ID into your terminal. The user sends her public key to EC2 Instance Connect using the AWS CLI. Power on the original EC2 instance and connect to this instance by using a new key pair via SSH. Connect to EC2 instances via SSH from your local Linux machine as explained above in this post. Copy the generated key string and save this information in a safe place.

How to connect to an EC2 instance using SSH

Using SSH through Session Manager works exactly like a normal SSH connection. The SSH through Session Manager solution works by creating an SSH tunnel through your Session Manager connection.

  • If everything is correct, a generated public key is displayed in the console output.
  • This will help to recognize the host each time you’re trying to connect to your instance.
  • Instructions for this are found in the How to Create a Basic Elastic Cloud Compute Instance data recipe.
  • This dialog is displayed when you connect to a particular remote machine for the first time.
  • I want to SSH AWS EC2 instance but by just only my computer, like SSH over the key.
  • Use the configuration as displayed on the screenshot below.

Next, you need to configure your SSH client. To do so, edit the ~/.ssh/config file on your local machine.

Google Cloud Services

First, we need to find out the availability zone the instance is running in. The command aws ec2 describe-instances returns the necessary information. Please note that %h will be replaced with the host, for example, i e6abc8fbe6b. You will use the AWS Command Line Interface to push your public key via EC2 Instance Connect and establish a tunnel for your SSH connection with the EC2 instance. Install the AWS CLI and the session manager plugin on your local machine.

Stop the original EC2 instance, the AWS SSH private key to which you have lost. It is required that your private key is not accessible by others.

How to Connect to EC2 with SSH Mac OS X

Since the AWS SSH configuration with both keys works fine, you can close the SSH terminal windows. You need to create a configuration file in JSON format.

This is usually in the Downloads folder unless you moved the file to another folder. Open another terminal on your local Linux machine and try to connect to the instance by using a new key. I go to the directory where my .pem key files are located.

Leave a Reply

Your email address will not be published. Required fields are marked *