• Arun Kumar

How to Setup SSH on EC2 Instances

I have created two EC2 instances on AWS. I created a key pair for each of them. I downloaded the .pem private keys and converted them into .ppk format. I can connect to each of my ec2 instances using PuTTY and their .ppk private key. But how do I SSH from one of my ec2 instance to the other? I can ping the Public DNS of either of them from the other. But if I try ssh from one to the other, I get:


Permission denied (publickey).

Setup SSH connection


On server A, run below command

ssh-keygen

Hit enter enter enter. You’ll have two files:

.ssh/id_rsa
.ssh/id_rsa.pub

On Server A, cat and copy to clipboard the public key:

cat ~/.ssh/id_rsa.pub
[select and copy to your clipboard]

Log onto server B, and add the public key from server A to authorized_keys file

vi ~/.ssh/authorized_keys
[paste your clipboard contents]
[save and close]

Now ssh from server A:

ssh <username>@<server_B>

Repeat the process from server B to server A if you want to setup ssh connection in the opposite direction.

18 views

Recent Posts

See All

Give Oracle user permissions to connect remotely

On a aws server, you need to connect via EC2-USER and then perform switch user to connect Oracle user. Use below commands to allow Oracle user connect the aws EC2 server remotely Connect EC2 server Co

Mount EFS on EC2 Instance

You might have created an Elastic File System (EFS) and now would like to mount it on EC2 instance. Get EFS link Check the EFS details and you should get a link which looks like below fs-06b8137f.efs.

Connect EC2 Server Without Keypair

You can enable keyless access on EC2 server that will allow you to connect to the server with username and password. Once you enable keyless access, you need not provide key file location under putty

  • Facebook
  • Twitter
  • YouTube
  • Instagram

© 2020 by DBA Genesis

Feedback