How to Block SSH password Dialog.



  • As i'm trying to transfer a file to the target from my GUI. i'm making use of SCP in backEnd, once i try to run a dialog coming up with asking password for authentication which is not designed by me. i don't know where its coming from?
    i want to have my own designed password dialog. is there any way to block that default dialog?


  • Moderators

    @moyin scp itself is a command line tool and does not show any dialogs. Can you describe more precise what you are doing? On what OS?
    "i'm making use of SCP in backEnd" - how?
    "once i try to run" - what?



  • @jsulm on pushbutton clicked event i'm running SCP ,so i'm getting
    password dialog that is may be from linux. i don't want to rely on that so i want to hav my own password dialog for my GUI.
    -or is there any other command instead of SCP that accepts password also as input parameter at a time?


  • Lifetime Qt Champion

    Hi,

    What Linux distribution ?

    Can you describe or show an image of that dialog ? It could very well be the unlocking of your session password storage.


  • Moderators

    @moyin How do you start scp? Using QProcess? Can you show the code?


  • Moderators

    @moyin You can avoid using passwords if you use public key authentication, see: https://kb.iu.edu/d/aews



  • @moyin
    I believe you can -B on the command-line to scp to prevent it prompting for a password. (It's worth a try just to see if the dialog goes away.) You will of course then get an error about "no password" instead. As @jsulm says, you could use public key auth instead. But scp does not allow password on command-line.

    For an alternative to scp, https://stackoverflow.com/a/47328516/489865 says curl does accept a command-line password.


  • Moderators

    @JNBarchan I'm wondering what password dialog is shown as scp is a pure command line tool and does not show any dialogs.
    I'm still waiting for more information on how exactly @moyin starts scp.



  • @jsulm
    I agree, but whatever the case if OP is not going to use key-gen and wants to supply password via command-line he's going to be stymied with scp.

    I have no idea whether there is any relation here, but I have a "password prompting dialog" that I don't understand where it's coming from under Ubuntu: when I go into MySQL Workbench first time in a session, it always says "my password has not been saved in the keyring and I need to enter it". It does not look like the dialog is coming from Workbench, more like it's coming from "Ubuntu/the desktop". Dunno if that could be related to his scp, or whether this only comes out of Workbench...



  • @jsulm
    How do you start scp? Using QProcess? Can you show the code?
    yeh! i'm using QProc, Here is my code

    
    void Transfer::on_pushButton_Go_clicked()
    {
        //proc = new QProcess() ;
        QString command = "scp" ;
        QString ip = ui->lineEdit_IP_Address->text() ;
        QString username = ui->lineEdit_SSH_username->text() ;
        QString dest_path = ui->lineEdit_TransferToTarget_DestinationFolder->text() ;
        QString source_path = ui->lineEdit_TransferToTarget_SourcePath->text() ;
        std::stringstream s ;
        s << username.toStdString() << "@" << ip.toStdString() << ":" << dest_path.toStdString();
        std::cout << s.str() << std::endl ;
        QStringList params ;
        params.append(source_path) ;
        params.append(QString::fromStdString(s.str())) ;
        qDebug() << params ;
        //    params.append("/home/span51/Desktop/readme.txt");
        //    params.append("spanidea@192.168.1.26:/home/spanidea/test" );
        qDebug() << connect(&proc, SIGNAL(readyReadStandardError()), this, SLOT(readOutput()));
        qDebug() << connect(&proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readOutput()));
        //    connect(&proc, SIGNAL(errorOccurred(QProcess::ProcessError error)), this, SLOT(readErr()));
        proc.start(command,params) ;
    
    }
    


  • @moyin
    Since as we've said scp will not accept a command-line argument for a password, what would you like to do about it in that light?



  • @JNBarchan is there any file_transfer command that accepts password as parameter.


  • Moderators

    @moyin Isn't public key authentication an alternative?



  • @moyin said in How to Block SSH password Dialog.:

    @JNBarchan is there any file_transfer command that accepts password as parameter.

    But I answered exactly this in my reply to you. Why do you think I wrote:

    For an alternative to scp, https://stackoverflow.com/a/47328516/489865 says curl does accept a command-line password.

    ?

    Or your alternative is @jsulm's public key for scp, as we have said.



  • how about sshpass?
    this will accept the password as argument along with username,ip,etc..,


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.