I am developing a program that is running on multiple machines using MPI.
I have machines on Amazon EC2 where I can start mpirun from one of them (the master).
Everything works as I expect if I ssh to the master machine, then trigger ssh-agent and then ssh-add my_rsa_key.
What I want to do, is to be able to have a script on my local machine where I trigger the mpirun on the master remotely with ssh, the problem is that I get Permission denied (Public key) because ssh-add is not receiving requests over that session (I suppose).
Here is a very basic draft of the deploy script I am trying right now.
#!/bin/bash
MACHINES_LIST="M1
M2"
echo $MACHINES_LIST | tr " " "\n" | while read fn; do
echo "$fn"
echo "deploying and compiling to : $fn ..."
scp -i key "sample.c" user@$fn:/home/user
ssh $fn 'mpicc sample.c -o sample' &
done
echo "uploading lists of hosts to master M"
scp -i key .hosts user@M:/home/user
echo "starting mpirun on master M"
##### Here mpirun needs to execute after ssh-add
ssh M 'exec ssh-agent bash;ssh-add my_rsa_key;mpirun --hostfile .hosts -np 10 sample'
Is there a way to make mpirun execute (remotely) within a session where ssh-add is running?