Reputation: 1917
How do I setup passwordless ssh between nodes on AWS cluster
Upvotes: 8
Views: 20946
Reputation: 1
How Did I Setup Password-Less Authentication between two Instances is the following:
cd ~/.ssh
and create a file vim target_instance_key.pem
and paste the contents of target_instance access key (which is created during launch of target_instance in AWS console) inside target_instance_key.pem
and save the file.target_instance_key.pem
i.e chmod 600 target_instance_key.pem
ssh-keygen -t rsa
ssh-copy-id -f "-o IdentityFile ~/.ssh/target_instance_key.pem" ubuntu@<TARGET_INSTANCE-PUBLIC-IP>
and for fingerprint type yes
and enter.ssh ubuntu@<TARGET_INSTANCE_PUBLIC-IP-ADDRESS>
and you have Logged in to the target_instance from server_instance through Password-Less Authentication.NOTE : server_instance can be any machine(i.e, EC2 instance (or) your local machine).
Upvotes: 0
Reputation: 11
how I made Paswordless shh work between two instances is the following:
create ec2 instances – they should be in the same subnet and have the same security group
Open ports between them – make sure instances can communicate to each other. Use the default security group which has one rule relevant for this case:
Log in to the instance you want to connect from to the other instance
Run:
1 ssh-keygen -t rsa -N "" -f /home/ubuntu/.ssh/id_rsa
to generate a new rsa key.
Copy your private AWS key as ~/.ssh/my.key (or whatever name you want to use)
Make sure you change the permission to 600
1 chmod 600 .ssh/my.key
Copy the public key to the instance you wish to connect to passwordless
1 cat ~/.ssh/id_rsa.pub | ssh -i ~/.ssh/my.key [email protected] "cat >> ~/.ssh/authorized_keys"
If you test the passwordless ssh to the other machine, it should work.
1 ssh 10.0.0.X
Upvotes: 1
Reputation: 13076
Following steps to setup password less authentication are tested thoroughly for Centos and Ubuntu.
Assumptions:
Steps:
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/*
Make sure sshing is permitted by the machine. In file /etc/ssh/sshd_config, make sure that 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
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
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>
Upvotes: 9
Reputation: 2695
This may help someone
Copy the pem file on the machine then copy the content of pem file to the .ssh/id_rsa file you can use bellow command or your own
cat my.pem > ~/.ssh/id_rsa
try ssh localhost it should work and same with the other machines in the cluster
Upvotes: 4
Reputation: 615
you can use ssh keys like described here: http://pkeck.myweb.uga.edu/ssh/
Upvotes: -5