Search code examples
ubuntuamazon-ec2load-testingtsung

tsung and ec2 - how to allow for passwordless logins for ubuntu


I have done the following for ubuntu on ec2.

1) My security group has ports 0-65000 open 2) I Turn of firewall by runnings these commands

iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

What more do I have to do to allow for tsung master to work with all of the slaves? How do I test if it works? I tired ssh but still asks for key.

ssh ec2-122-248-xxx-xxx.ap-southeast-1.compute.amazonaws.com erl
Permission denied (publickey).

Solution

  • Here's what I use - I first edit my hosts file and insure that I have names for all my machines in there (you could use DNS as well, but I'd rather keep costs down and use internal IP's instead), then I run:

        #!/bin/bash
    
        myrsapub=`cat ~/.ssh/id_rsa.pub`
    
        for i in <my_machine_names_space_delimited>; do
    ssh $i -i ~/.ssh/<my_amazon_key> "echo $myrsapub | tee -a ~/.ssh/authorized_keys; ssh-keygen -t rsa << hereintime
    
    
    
        hereintime; sudo hostname $i; exit" &> /dev/null
            ssh $i "echo \"host *
            user ubuntu
            StrictHostKeyChecking no\" | tee -a .ssh/config; sudo sed -i.bak -e \"s/localhost/localhost $i/\" -e \"/$i/d\" /etc/hosts; echo \"# need to have ssh-agent         running
        eval \`ssh-agent\`
        [ -e /home/ubuntu/.ssh/id_rsa.pub ] && ssh-add\" | tee -a ~/.bashrc" &> /dev/null
            newhostline=`grep $i /etc/hosts`
            ssh $i "sudo sed -i -e \"/$i/d\" /etc/hosts; echo $newhostline | sudo tee -a /etc/hosts" &> /dev/null
            <LOAD_MASTER>=`grep <LOAD_MASTER> /etc/hosts` && ssh $i "sudo sed -i -e '/<LOAD_MASTER>/d' /etc/hosts" &> /dev/null
            ssh $i "rm ~/.ssh/known_hosts; echo $<LOAD_MASTER> | sudo tee -a /etc/hosts; ssh <LOAD_MASTER> \"exit\""  &> /dev/null
            ssh $i "cat ~/.ssh/id_rsa.pub" | tee -a ~/.ssh/authorized_keys
            ssh $i "sudo hostname $i; exit"
         done