2

I have 3 EC2 instances and they all use the same private key. I'm setting up a hadoop cluster between these nodes and they require passwordless entry for this to work.

How can I use this private key to easily ssh into the servers with keyless entry?

The only thing I have is a .pem file. I've scp'ed the file into the master server.

coderkid
  • 173
  • 1
  • 5

1 Answers1

1

You want to create a ~/.ssh/config file with the necessary entries. The equivalent of the -i command line option is the IdentityFile command in the configuration file.

Host my.domain.com
  HostName other-name
  User me
  PreferredAuthentications publickey
  Port 2222
  IdentityFile /home/me/.ssh/other_keys/other_id_rsa

More info about the configuration file can be found in man ssh_config.

IMPORTANT NOTE: If you are to use many such keys, place them in a sub-directory otherwise you will get failures because ssh tries to login with all the keys found directly under ~/.ssh. However, most servers will accept 3 to 5 attempts. More keys in the .ssh folder and it is likely to fail many login attempts unless you use the -i option or the configuration file.

Alexis Wilke
  • 2,057
  • 1
  • 18
  • 33
  • @coderkid, if that's your solution then you may want to click on the big checkmark on the side of the answer to mark it as the one that made it work for you. – Alexis Wilke Sep 26 '16 at 17:26