Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution
Highlighted

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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

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

@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
Highlighted

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

Super Collaborator

Hi @kishore sanchina

I assuming both are linux servers.

Please folllow the steps in mentioned url: http://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/

Highlighted

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

Hi @subhash parise i know how to create password less ssh in linux. but i dont kown how to create password less ssh in ec2 instances.

Highlighted

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

Super Collaborator

Hi @kishore sanchina,

same mechanism will apply ec2 instances also :)

Highlighted

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

@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

Highlighted

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

New Contributor

Kishore.. enable the below parameter under /etc/ssh/sshd_config

# To disable tunneled clear text passwords, change to no here!

PasswordAuthentication yes

and add the hostnames under /etc/hosts.. then follow the regular ssh procedure.

,

Hi Kishore,

to create password less ssh, first enable "authenticationpassword yes" option under /etc/ssh/sshd_config. add hostnames under /etc/hosts . then follow the regular ssh procedure. first check the ping is working from one instance to other or not?

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

Explorer

Hi how can i do the same with a local system running Windows?

Highlighted

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

Super Mentor
Highlighted

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

Explorer

Thanks @Jay SenSharma. I used this document but I can't achieve what I want to do : setup password-less SSH between my EC2 instances running RHEL7 from my local machine running Windows. I've open a new thread (here) to give more details.

Highlighted

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

Contributor

This is probably the best link which I have found on how to setup the passwordless login using ssh-copy-id command on ec-2 instances.

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

Probably, this might help.

Don't have an account?
Coming from Hortonworks? Activate your account here