martymac / fpart

Sort files and pack them into partitions
https://www.fpart.org/
BSD 2-Clause "Simplified" License
231 stars 39 forks source link

using sshpass does not seem to work with fpsync #60

Closed yghorbal closed 8 months ago

yghorbal commented 8 months ago

I'm trying to use sshpass for "reasons". This works out of the box: SSHPASS=somepassword sshpass -e rsync -av src/ user@server:dst/

But when using fpsync it gets stuck in the ssh phase SSHPASS=somepassword sshpass -e fpsync -n 4 -f 3 src/ server:dst/

parts are generated successefully, 4 rsync processes are started and subsequent 4 ssh processes but all of them are stuck in the T state (my guess that sshpass magic somehow stop to operate and ssh is waiting for user input)

Is there any way to use fpsync inside sshpass?

martymac commented 8 months ago

Hello Youssef !

Fpsync starts ssh commands in the background through a non-interactive shell, thus stdin is redirected from /dev/null (at least on FreeBSD) and I don't know how sshpass can cope with that. The best way to connect passwordless is probably to use a ssh key (playing with a ssh_config(5) file) but if you want to try to hack around ssh calls, check the SSH_BIN variable (https://github.com/martymac/fpart/blob/master/tools/fpsync#L1104). You may want to initialize it with sshpass instead of ssh and add a SSH_OPTS variable. Something like :

SSH_BIN="$(command -v sshpass)" SSH_OPTS="$(command -v ssh)"

and then add ${SSH_OPTS} to ${SSH_BIN} calls later in the code.

Tell me how it goes, those two variables could become new options to fpsync :)

yghorbal commented 8 months ago

Hello @martymac, thank you for the quick reply. Just to be clear about my use case, I'm not trying to use sshpass for Fpsync SSH workers. I'm trying to use it only for the SSH session of Rsync itself. I'll mess around with the script and see how things goes, and report back.

yghorbal commented 8 months ago

@martymac I've managed to make it work as I wanted

martymac commented 8 months ago

Wow, perfect ! And thanks for your feedback :)

Cheers,

Ganael.