1
votes

I am writing a console-application in Delphi (for Windows), which uses the plink.exe in the background to connect to a device via ssh (redirecting stdin and stdout).

My wrapper is using the plinkremote component (http://www.delphipraxis.net/70989-komponente-fuer-ssh-verbindung-6.html).

To start a connection I have my wrapper ask the user for the username and password and then run the command [plink -pw "password" user@server], it connects and I am connected through my wrapper to the server.

Everything works as expected with one exception: If I type the password incorrectly the latest version of plink (ver. 0.63) comes up with an "interactive keyboard authentication" and asks for a password. At that point my wrapper stops working. Whatever I am typing is not being forwarded to the server, and the only way to get out is to close the command-prompt window all together. I found a way to disable this "interactive authentication" (by saving a putty-session with it disabled and loading that session within my wrapper), but plink still comes up with asking for a password, and my wrapper stops working the same way.

For the last few days I am trying to figure out why it stops working. I am not sure if in- or output gets redirected somewhere else (only when plink asks for a password). I would prefer plink to just close the connection if it cannot authenticate, then I could try to connect again right away, hopefully type the password correctly and be connected. A previous version of plink (ver. 0.60) does exactly that. Of course I would prefer to use the latest plink version, so I would like to figure out what is going on when plink cannot connect with the given credentials.

I did search and could not find a solution to this issue - the only question which sounds to be a similar issue was not answered (https://stackguides.com/questions/19458241/redirecting-the-dev-tty-for-a-plink-command).

Does anyone have an idea what might be wrong or how to disable the password-question in plink completely?

Thank you!

1
Well, after a week of trying to find out what's going on with plink's input & output, I gave up and recognize the "user@server's password" question from plink. If I see that question, I just exit my program (the wrapper) to get back to the command prompt. Not at all what I want to do, but at least I can use my program like this until I figure out what plink is doing. - Mordin
Ok, now I feel a bit silly. I must have overlooked the "-batch" option of plink. With it, plink will "disable all interactive prompts" and not ask for a password, should it be wrong. I would still like to figure out what plink is doing, but at least it does not "crash" my wrapper. - Mordin

1 Answers

0
votes

Here is a good plink reference:

http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html

and here's standard batch file code

structure: Debug\plink -[connection type] [ipaddress] -l [username] -pw [password]

example: Debug\plink -ssh 192.168.1.1 -l sudo -pw MyWeakestPasswordEver