3

So I am running a parallel c++ program by sending jobs from an Ubuntu machine to remote hosts (also Ubuntu), the command line I use on the terminal is something like:

mpirun -np 4 --host host1,host2 program.exe

and then the next line on the terminal requests the password for both hosts at the same time:

noob@host1's password: noob@host2's password:

And this is causing me some problems. Is there a way to force the terminal to request my passwords one by one?

terdon
  • 98,183
  • 15
  • 197
  • 293

2 Answers2

2

I don't know if there's a way to force the terminal to ask sequentially but in any case, assuming you are connecting through ssh, a better solution would be to set up passwordless access.

  1. Create a public ssh key on your machine:

    ssh-keygen -t rsa
    

    You will be asked for a passphrase which you will be asked to enter the first time you run any ssh command after each login. This means that for multiple ssh or scp commands, you will only have to enter it once (not once per host, once per login session). Nevertheless, you can leave it empty to have completely passwordless access.

  2. Once you have generated your public key, copy it over to the remote computers:

    ssh-copy-id -i ~/.ssh/id_rsa.pub noob@host1
    ssh-copy-id -i ~/.ssh/id_rsa.pub noob@host2
    

    If you need to do this for many hosts, make a file of the hostnames or IPs (one per line) and run copy them all using a shell loop:

    while read ip; do 
         ssh-copy-id -i ~/.ssh/id_rsa.pub noob@$ip 
    done < IPlistfile.txt
    

You will have to manually enter the password for each IP for this step, but once you've done that, you should be able to launch your jobs with no password being requested.

If that doesn't work, we will need more details on how exactly this program connects to the remote hosts.

terdon
  • 98,183
  • 15
  • 197
  • 293
0

If you are using MPICH1 you can get help from this method.

Instead of writing host1,host2 after -np 4 you can add hosts to "machines.linux" file in this destination:

home/user/mpich1/share

*if you didn't install mpich in home directory, refer to where you installed mpich

and open "machines.linux" file. Clear contents of the file and type information of hosts with the number of cores you want:

host1:4  
host2:2
host3:2

Now you use mpirun simply:

mpirun -np 4 program.exe
Ali Tohidi
  • 11
  • 5