Unable to run QProcess with sshpass in Windows
-
wrote on 26 May 2021, 18:19 last edited by
Hi all,
I am trying to copy a file over ssh by passing the password through sshpass in windows. Surprisingly each command works like date, time while using the same code but sshpass appears doesn't execute at all. Here is what my code looks like-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { myProcess = new QProcess(this); connect (myProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_readStandardOutput())); connect (myProcess, SIGNAL(readyReadStandardError()), this, SLOT(slot_readStandardError())); connect (myProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slot_processFinished(int, QProcess::ExitStatus))); connect (myProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(slot_processErrorOccured(QProcess::ProcessError))); myProcess->start("cmd.exe", QStringList() << "C:/cygwin64/bin/sshpass.exe -p password C:/cygwin64/bin/scp.exe -r pi@192.168.5.16:/home/pi/Test .", QIODevice::ReadOnly); }
But execution of "C:/cygwin64/bin/sshpass.exe -p password C:/cygwin64/bin/scp.exe -r pi@192.168.5.16:/home/pi/Test ." works fine on command prompt. Any help is appreciated. Thanks
-
@Christian-Ehrlicher said in Unable to run QProcess with sshpass in Windows:
This is for sure not correct since sshpass wants single arguments (at least I would guess so).
sshpass asks for password which goes with -p, this is what its usage says -
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used@Ryna
Hi
Do we need to run it via CMD ?why not like
Process->start("C:/cygwin64/bin/sshpass.exe", QStringList() << "-p" << "password" << "C:/cygwin64/bin/scp.exe" << "-r" << "pi@192.168.5.16:/home/pi/Test", QIODevice::ReadOnly);
-
@Ryna said in Unable to run QProcess with sshpass in Windows:
"C:/cygwin64/bin/sshpass.exe -p password C:/cygwin64/bin/scp.exe -r pi@192.168.5.16:/home/pi/Test ."
This is for sure not correct since sshpass wants single arguments (at least I would guess so).
-
@Ryna said in Unable to run QProcess with sshpass in Windows:
"C:/cygwin64/bin/sshpass.exe -p password C:/cygwin64/bin/scp.exe -r pi@192.168.5.16:/home/pi/Test ."
This is for sure not correct since sshpass wants single arguments (at least I would guess so).
wrote on 26 May 2021, 18:37 last edited by@Christian-Ehrlicher said in Unable to run QProcess with sshpass in Windows:
This is for sure not correct since sshpass wants single arguments (at least I would guess so).
sshpass asks for password which goes with -p, this is what its usage says -
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used -
@Christian-Ehrlicher said in Unable to run QProcess with sshpass in Windows:
This is for sure not correct since sshpass wants single arguments (at least I would guess so).
sshpass asks for password which goes with -p, this is what its usage says -
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used@Ryna
Hi
Do we need to run it via CMD ?why not like
Process->start("C:/cygwin64/bin/sshpass.exe", QStringList() << "-p" << "password" << "C:/cygwin64/bin/scp.exe" << "-r" << "pi@192.168.5.16:/home/pi/Test", QIODevice::ReadOnly);
-
@Christian-Ehrlicher said in Unable to run QProcess with sshpass in Windows:
This is for sure not correct since sshpass wants single arguments (at least I would guess so).
sshpass asks for password which goes with -p, this is what its usage says -
Usage: sshpass [-f|-d|-p|-e] [-hV] command parameters
-f filename Take password to use from file
-d number Use number as file descriptor for getting password
-p password Provide password as argument (security unwise)
-e Password is passed as env-var "SSHPASS"
With no parameters - password will be taken from stdin-P prompt Which string should sshpass search for to detect a password prompt
-v Be verbose about what you're doing
-h Show help (this screen)
-V Print version information
At most one of -f, -d, -p or -e should be used@Ryna said in Unable to run QProcess with sshpass in Windows:
sshpass asks for password which goes with -p, this is what its usage says -
But it needs it as single arguments, not as one.
-
@Ryna
Hi
Do we need to run it via CMD ?why not like
Process->start("C:/cygwin64/bin/sshpass.exe", QStringList() << "-p" << "password" << "C:/cygwin64/bin/scp.exe" << "-r" << "pi@192.168.5.16:/home/pi/Test", QIODevice::ReadOnly);
wrote on 26 May 2021, 18:57 last edited by Ryna@mrjj said in Unable to run QProcess with sshpass in Windows:
C:/cygwin64/bin/sshpass.exe", QStringList() << "-p" << "password" << "C:/cygwin64/bin/scp.exe" << "-r" << "pi@192.168.5.16:/home/pi/Test", QIODevice::ReadOnly);
I tried this and it worked. It was just copying it to different location. I can try to debug and figure that out.. Thank you so much.
-
@Ryna said in Unable to run QProcess with sshpass in Windows:
sshpass asks for password which goes with -p, this is what its usage says -
But it needs it as single arguments, not as one.
wrote on 26 May 2021, 19:02 last edited by@Christian-Ehrlicher
I understood what you meant to say. This worked.. Thank you so much :)
1/7