Passwordless SSH from Master to Slave on AWS EMR

Upload pem file to master node and SSH to master

scp -i admin-key.pem admin-key.pem ec2-user@ecIP.eu-west-1.compute.amazonaws.com:~/
aws emr ssh --cluster-id JOB_ID

Configure passwordless SSH from master to slaves

# Identify IPs of slave nodes, 
hdfs dfsadmin -report | grep ^Name | cut -f2 -d:| cut -f2 -d' '
ssh-agent bash
ssh-add YOUR_AWS_IAM.pem
ssh-keygen [enter enter]
ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop@IP_OF_SLAVE

Reference for ssh-agent.

Use Git with specific ssh-key

The following is a work around for git users to specify his/her ssh-key when using git on a remote/public server.

sudo ssh-agent bash -c 'ssh-add /home/folder/id_rsa; git clone git@host.com:folder/'
sudo ssh-agent bash -c 'ssh-add /home/folder/id_rsa; git push'
sudo ssh-agent bash -c 'ssh-add /home/folder/id_rsa; git pull'
sudo ssh-agent bash -c 'ssh-add /home/folder/id_rsa; git ...'