Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProcess ssh Pseudo-terminal will not be allocated because stdin is not a terminal
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _hunter
    wrote on last edited by
    #1

    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

    JonBJ 1 Reply Last reply
    0
    • _ _hunter

      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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @_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.

      1 Reply Last reply
      1
      • _ Offline
        _ Offline
        _hunter
        wrote on last edited by
        #3

        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

        _ 1 Reply Last reply
        0
        • _ _hunter

          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

          _ Offline
          _ Offline
          _hunter
          wrote on last edited by
          #4

          @JonB I just updated this problem.

          JonBJ 1 Reply Last reply
          0
          • _ _hunter

            @JonB I just updated this problem.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @_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?

            _ 1 Reply Last reply
            0
            • JonBJ JonB

              @_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?

              _ Offline
              _ Offline
              _hunter
              wrote on last edited by
              #6

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

              JonBJ 1 Reply Last reply
              0
              • _ _hunter

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

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #7

                @_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.

                Pablo J. RoginaP 1 Reply Last reply
                0
                • JonBJ JonB

                  @_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.

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #8

                  @_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

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  1

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved