Plink version 0.83 not using STDOUT or STDERR? - Stack Overflow

For SSH-connections I wrote a "wrapper" (to do automatic IP-address lookups etc.) and in the

For SSH-connections I wrote a "wrapper" (to do automatic IP-address lookups etc.) and in the background it is using Plink.exe (the CLI version of PuTTY). This was working very well for a while now. Unfortunately with the latest version (0.83) I just downloaded something changed. At first I thought my wrapper needed to be adjusted, but then I realized it might not have to do anything with my wrapper at all. It seems the latest Plink.exe version does not use STDOUT or STDERR for all output.

Here are the things I tested: Specifically if the host key of a server is not saved yet and it shows

host key is not cached ... The server's rsa2 key fingerprint is: ...If you trust this host, enter "y" ...".

This text-block is apparently sent directly to the Console (and not STDOUT or STDERR) with the latest 0.83 version.

I did the following redirection test with 2 different Plink versions (to a host where the host-key is not stored yet):

plink.exe -pw "password" [email protected] > C:\DATA\STDOUT.txt 2> C:\DATA\STDERR.txt

When I do this with Plink version 0.80 it takes the command and nothing else shows up in the CLI-window (like it should be as STDOUT and STDERR are being redirected into the 2 files). The same command using Plink version 0.83 I get the following output in the CLI-window:

The host key is not cached for this server:
  10.1.24.1 (port 22)
You have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
  ssh-rsa 2048 SHA256:OurTXI1/ilANVeettt4fgeQWD7INzksLaRzcemYevLk
If you trust this host, enter "y" to add the key to Plink's
cache and carry on connecting.
If you want to carry on connecting just once, without adding
the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info)

Why is this not sent out via STDOUT or STDERR? I read online this might happen if the program is writing directly to CON (Console), but I am not sure ... I never had this type of issue. Obviously my wrapper cannot act on these messages as it does not "see" them.

Is there a way to convince Plink to use the standard handles? At this point I am scratching my head not sure what to do next.

This link (talking about C#, but also has a redirect "problem"). One answer suggests that it might be difficult to do ... Capture ALL (stdout, stderr AND CON) output of cmd executing plink with C# (std out+err ok, CON not working)

Thanks for any help/ suggestion!

For SSH-connections I wrote a "wrapper" (to do automatic IP-address lookups etc.) and in the background it is using Plink.exe (the CLI version of PuTTY). This was working very well for a while now. Unfortunately with the latest version (0.83) I just downloaded something changed. At first I thought my wrapper needed to be adjusted, but then I realized it might not have to do anything with my wrapper at all. It seems the latest Plink.exe version does not use STDOUT or STDERR for all output.

Here are the things I tested: Specifically if the host key of a server is not saved yet and it shows

host key is not cached ... The server's rsa2 key fingerprint is: ...If you trust this host, enter "y" ...".

This text-block is apparently sent directly to the Console (and not STDOUT or STDERR) with the latest 0.83 version.

I did the following redirection test with 2 different Plink versions (to a host where the host-key is not stored yet):

plink.exe -pw "password" [email protected] > C:\DATA\STDOUT.txt 2> C:\DATA\STDERR.txt

When I do this with Plink version 0.80 it takes the command and nothing else shows up in the CLI-window (like it should be as STDOUT and STDERR are being redirected into the 2 files). The same command using Plink version 0.83 I get the following output in the CLI-window:

The host key is not cached for this server:
  10.1.24.1 (port 22)
You have no guarantee that the server is the computer you
think it is.
The server's rsa2 key fingerprint is:
  ssh-rsa 2048 SHA256:OurTXI1/ilANVeettt4fgeQWD7INzksLaRzcemYevLk
If you trust this host, enter "y" to add the key to Plink's
cache and carry on connecting.
If you want to carry on connecting just once, without adding
the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info)

Why is this not sent out via STDOUT or STDERR? I read online this might happen if the program is writing directly to CON (Console), but I am not sure ... I never had this type of issue. Obviously my wrapper cannot act on these messages as it does not "see" them.

Is there a way to convince Plink to use the standard handles? At this point I am scratching my head not sure what to do next.

This link (talking about C#, but also has a redirect "problem"). One answer suggests that it might be difficult to do ... Capture ALL (stdout, stderr AND CON) output of cmd executing plink with C# (std out+err ok, CON not working)

Thanks for any help/ suggestion!

Share Improve this question edited Mar 24 at 6:02 Martin Prikryl 203k64 gold badges547 silver badges1.1k bronze badges asked Mar 20 at 20:03 MartinMartin 133 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It's due to this change in PuTTY 0.82:
Send Windows console tools' prompts directly to the console

A possible workaround is mentioned there:

If this change causes a problem for you, you can get the old behaviour by adding the option -legacy-stdio-prompts to the command line.

The -legacy-stdio-prompts switch is documented here:
https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline-legacy-stdio-prompts


Though a better solution is to pass an expected hostkey fingerpring using -hostkey switch to avoid getting the prompt in the first place:
https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter3.html#using-cmdline-hostkey

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744386701a4571699.html

相关推荐

  • Plink version 0.83 not using STDOUT or STDERR? - Stack Overflow

    For SSH-connections I wrote a "wrapper" (to do automatic IP-address lookups etc.) and in the

    7天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信