Sign in to follow this  
Followers 0
lelapinbleu

how send passphrase to plink?

4 posts in this topic

hello

I'm wondering if any of you so clever people that I respect so much I'm down on my knees right now, could you make me the honor ,the pleasure to eventualy if you have some time because try to respond to me.

I'm trying to autoit the plink connexion. It needs a passphrase. passphrase cant be added unfortunatly to sessions files and I can't use peagent.

Here is my so stupid little code you will of course find so bad but my mind is narrow and I'm so stupid compared to you all that I'm quite ashame to show it to you.

#include <Constants.au3>

dim $data

Local $pid = Run(@ComSpec, "c:\", @SW_SHOW, $STDIN_CHILD + $STDERR_MERGED)

StdinWrite ($pid, "plink.exe 123.123.123.123 -N -ssh -2 -P 22 -l someusername -C -D 8080 -i keyfile.ppk -v " & @CRLF)

Sleep(10)

StdinWrite($pid, "1") ; no CR needed

Sleep(5)

StdinWrite($pid, "2") ; no CR needed

Sleep(5)

StdinWrite($pid, "3") ; no CR needed

Sleep(5)

StdinWrite($pid, "4" & @CRLF)

Sleep(5)

StdinWrite($pid, "5" & @CRLF)

Sleep(1)

StdinWrite($pid, "Q" & @CRLF) ; send some quit command to your app to exit back to console!

StdinWrite($pid, "exit" & @CRLF); send exit command to @ComSpec to trigger stdout!

While 1

$data &= StdoutRead($pid)

If @error Then ExitLoop

Wend

ConsoleWrite($data)

If StringInStr($data, "<Acces granted>") <> 0 Then

MsgBox(0, "Test Passed!", $data)

Else

MsgBox(0, "Test Failed!", $data)

EndIf

I tried different sleep time ( 50, 100 etc). I always get a prompt for Passphrase..( 1,2345 are not printed on result box.)

any clever idea would be so much appreciate .

your servant.

thank you , and so sorry for disturbing you. please forgive my rudness. and pleasse forgive my language I'm not english.

Share this post


Link to post
Share on other sites



Is there a reason that you need to run cmd first? I would have thought this would be possible:

Local $pid = Run("plink.exe 123.123.123.123 -N -ssh -2 -P 22 -l someusername -C -D 8080 -i keyfile.ppk -v", @SW_SHOW, $STDIN_CHILD + $STDERR_MERGED)

Share this post


Link to post
Share on other sites

Is there a reason that you need to run cmd first? I would have thought this would be possible:

Local $pid = Run("plink.exe 123.123.123.123 -N -ssh -2 -P 22 -l someusername -C -D 8080 -i keyfile.ppk -v", @SW_SHOW, $STDIN_CHILD + $STDERR_MERGED)

unfortunatly it doesnt work I tried that before but I get the " test failed" msg box immediatly in that case.

Share this post


Link to post
Share on other sites

I dont see the edit button so . As I said I'm stupid. I didnt realize Passphrase is not printed on screen :x . So It works in a way.

So this script launch a blank command window and if I click on " x " to close the window it shows the result. what I would like is to see the result ( the output) in real time in a text box... Or be able to parse the output inr eal time so when " access granted" is outputed by plink I can lauch a msg box that says " you are connected ".

thanks a lot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0