Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QProcess ssh Pseudo-terminal will not be allocated because stdin is not a terminal



  • I tried to use QProcess ssh to a remote server,but i always get this"Pseudo-terminal will not be allocated because stdin is not a terminal".when i tried to add options "-Tt",I get
    "
    unknown option --

    usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-E log_file] [-e escape_char]
    [-F configfile] [-I pkcs11] [-i identity_file] [-L address]
    [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
    [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
    [-w local_tun[:remote_tun]] [user@]hostname [command]
    ".

    here are my code.
    QStringList args;
    args.append("root@127.0.0.1");
    args.append("vuls report -format-full-text");
    QProcess *proc = new QProcess;
    proc->setStandardErrorFile("err.txt");
    proc->setStandardOutputFile("ou1.txt");
    proc->setWorkingDirectory("/root/");
    proc->start("ssh",args);

    who can help me?or give me some hint



  • @_hunter

    I don't know how you tried to add -Tt (assuming that would address the error) as your code does not show it!

    I din't know what your existing vuls report -format-full-text argument is about either. But for all options you must add each one as a separate argument. Unless that is a single argument (which you would quote on the command line) it's wrong.

    args.append("root@127.0.0.1");
    args.append("-Tt");
    args.append("vuls");
    args.append("report");
    ...
    

    or you can shortcut to a single line using the C++ << operator for each element in the list.



  • here how "-Tt" added
    “QStringList args;
    args.append("-Tt");
    args.append("root@127.0.0.1");

    args.append("vuls");
    args.append("report");
    args.append("-format-full-text");
    
    
    QProcess *proc = new QProcess;
    
    proc->setStandardErrorFile("err.txt");
    proc->setStandardOutputFile("ou1.txt");
    
    proc->setWorkingDirectory("/root/");
    
    proc->start("ssh",args);"
    

    here are error message,in the "err.txt":
    "
    Pseudo-terminal will not be allocated because stdin is not a terminal.

    bash: vuls: command not found"

    and vuls(Vulnerability scanner https://github.com/future-architect/vuls ) is a service in the server.
    and this is the way vuls wroks,in the terminal :
    0_1526995219781_W84.png



  • @JonB I just updated this problem.



  • @_hunter

    1. I thought you meant that ssh -Tt solved your "stdin" problem. If it still errors, then your problem is not about the command-line arguments but rather the underlying stdin behaviour....

    2. For your vuls, if what you show is that you have to run sudo su first, then how do we know it's runnable/on your path from within Qt app?

    Why don't you start by clearly explaining what commands, with what arguments, you are trying to run, and what the behaviour is?



  • @JonB sorry ,i do not think you can understand my meaning and where the problem is



  • @_hunter
    LOL, as you please :) I know what your problem is: you do not have a pseudo-tty to pass on stdin to ssh, you are trying to pass the right command-line arguments to by-pass that need, and you are blaming QProcess when you're not passing the arguments correctly, which is not its fault. Good luck.



  • @_hunter maybe the problem is this parameter "-Tt"?
    From man ssh:

     -T      Disable pseudo-tty allocation.
    
    -t      Force pseudo-tty allocation.  This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g., when implementing menu services.  Multiple -t options force tty allocation, even if ssh has no local tty.
    

    So it looks like you might not be actually enabling pseudo-tty allocation, required for remote process execution I guess


Log in to reply