Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

how to create password less ssh between two AWS EC2 instances?

avatar
Not applicable

how to create password less ssh between 2 AWS EC2 instances.

1 ACCEPTED SOLUTION

avatar
Super Guru

@kishore sanchina

Subash is correct. It is not that different.

Pre-reqs:

1. access to your EC2 machine and using the pem key or credentials with root permissions.

2. already setup RSA keys on your local machine. Private key and public key are available at "~/.ssh/id_rsa" and "~/.ssh/id_rsa.pub", respectively.

Steps:

  1. Login to you EC2 machine as a root user.
  2. Create a new user
    useradd -m <yourname> 
    sudo su <yourname>
    cd 
    mkdir -p ~/.ssh
    touch ~/.ssh/authorized_keys
    

    Append contents of file ~/.ssh/id_rsa.pub on you local machine to ~/.ssh/authorized_keys on EC2 machine.

    chmod -R 700 ~/.ssh
    chmod 600 ~/.ssh/*
    
  3. Check whether ssh-ing is permitted by the machine. It should. In /etc/ssh/sshd_config, line containing "PasswordAuthentication yes" is uncommented. Restart sshd service if you make any change in this file:
    service sshd restart # On Centos
    service ssh restart # On Ubuntu
    
  4. Your passwordless login should work now. Try following on your local machine:
    ssh -A <yourname>@ec2-xx-xx-xxx-xxx.ap-southeast-1.compute.amazonaws.com
    
  5. Making yourself a super user. Open /etc/sudoers. Make sure following two lines are uncommented:
    ## Allows people in group wheel to run all commands
    %wheel ALL=(ALL)       ALL
    
    ## Same thing without a password
    %wheel ALL=(ALL)       NOPASSWD: ALL
    

    Add yourself to wheel group.

    usermod -aG wheel <yourname> 

Try it and let me know.

View solution in original post

10 REPLIES 10

avatar
New Member

https://superuser.com/questions/331167/why-cant-i-ssh-copy-id-to-an-ec2-instance

Go through above link it will help you to findout easily