how to use Parallel SSH with Amazon EC2 instances?

I am trying to run an Parallel SSH with Amazon Instances, But I am getting Permission denied expception, How ever I can SSH it to the server. How we can run PSSH with key login. So far I have tried like,

pssh -h hosts-file -i xxx.pem -l username date

Solution 1:

use the -x argument.

Example

pssh  -i  -H [email protected]  -x "-oStrictHostKeyChecking=no  -i /home/ccc/xxx/something-us-east.pem" 'echo hi'

Whatever u put in -x gets passed as arguments to the underlying ssh process.

Solution 2:

The -i parameter of parallel-ssh doesn't specify the keyfile like it does for ssh. You need to add something like this to your ~/.ssh/config to get SSH to use the right keyfile.

Host *.compute-1.amazonaws.com
    IdentityFile ~/.ssh/ec2.pem