Topo
Topo

Reputation: 5002

Executing SCP in GNU Parallel

I need to run some commands in parallel including SCP. For this I'm using GNU Parallel. The problem is I don't know how to pass the password to SCP. This is a line similar to the one I'm running:

ls 2011_* | parallel scp {} user@domain

And if ls finds 3 files, scp ask 3 times for password at the same time and I can only input the password to the last process to prompt for it.

I temporarily solved this issue connecting using a public key, but this won't be an option in the future due to company policies. I read the SCP man pages and I couldn't find an option, but I'm quite confident that Parallel should have an option to allow me to input the password.

Somebody knows a way to solve this?

EDIT: I want to know if there is a way I can tell parallel the password so it can give it to scp each time it asks for it. Maybe with something like this:

ls 2011_* | parallel scp {} user@domain < file_with_password.txt

But specifying that the redirection of STDIN is for scp and not for ls or parallel.

Upvotes: 5

Views: 2208

Answers (2)

Ole Tange
Ole Tange

Reputation: 33685

You will want to look at ssh-agent: The benefit of having a passphrase protected certificate with the convenience of typing your passphrase only once.

GNU Parallel >= 20220322 supports this syntax if you have sshpass installed:

parallel -S user:password@server ...

Upvotes: 4

Jordan
Jordan

Reputation: 465

parallel sshpass -p $PASS scp -P $PORT -rp {} ~/to_dir ::: $ADDRESS:~/from_dir/*

Upvotes: 2

Related Questions