Jump to content


Recommended Posts


  Hi to all,



I only am accustomed pas has posted on the forum (coz, I'm french). But I use it a lot.

So first of all, thank you all to participate in the evolution of this wonderful product.

Today is not one day like any other, I myself am decide has posted a UDF that I myself create and developed (there may be some bug) for some months.

So here it is:

This UDF allows to use the SSH protocol very easily in your code.

It uses the syntax as the TCPxxx() function.

Your code will be easier to convert :-).


excused my English, I'm French.




#cs ----------------------------------------------------------------------------

AutoIt Version:
Author: Joseph Barone 2010-2015

Script Function:
Modele pour l'utilisation de la fonction ssh (plink).

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include "SSH_udf.au3"


Global $butt[6]

$Gui = GUICreate("SSH Console",550,400)
$label1 = GUICtrlCreateLabel("Adresse IP:",10,10,150,20) ; ip
$input1 = GUICtrlCreateInput("",10,25,150,20) ; ip
$label2 = GUICtrlCreateLabel("Tcp port:",170,10,150,20) ; port
$input2 = GUICtrlCreateInput("",170,25,60,20) ; port
$label6 = GUICtrlCreateLabel("Protocol:",240,10,40,20) ; port
$input6 = GUICtrlCreateInput("ssh",240,25,60,20) ; port
$butt[0] = GUICtrlCreateButton("Connect0",310,5,80,20,$BS_DEFPUSHBUTTON)
$butt[1] = GUICtrlCreateButton("Connect1",390,5,80,20)
$butt[2] = GUICtrlCreateButton("Connect2",470,5,80,20)
$butt[3] = GUICtrlCreateButton("Connect3",310,25,80,20)
$butt[4] = GUICtrlCreateButton("Connect4",390,25,80,20)
$butt[5] = GUICtrlCreateButton("Connect5",470,25,80,20)

$Checkbox = GUICtrlCreateCheckbox("RSA, Fingerprint, Alert AutoValidate", 330, 45, 205, 25)

$label4 = GUICtrlCreateLabel("Login:",10,45,150,20) ; login
$input4 = GUICtrlCreateInput("",10,60,150,20) ; login
$label5 = GUICtrlCreateLabel("Mot de passe:",170,45,150,20) ; password
$input5 = GUICtrlCreateInput("",170,60,150,20,$ES_PASSWORD) ; password

$label3 = GUICtrlCreateLabel("Commande a envoyer:",10,85,150,20) ; send command
$input3 = GUICtrlCreateInput("",10,100,310,20) ; send commande vers l'hote
$butt2 = GUICtrlCreateButton("Send",330,100,80,20,$BS_DEFPUSHBUTTON)

$edit = GUICtrlCreateEdit("",10,130,530,260,$WS_VSCROLL);,$WS_DISABLED))


Global $ConnectedSocket[6] = [-1,-1,-1,-1,-1,-1]
Global $msg, $recv, $ret

; GUI Message Loop
While 1
$nmsg = GUIGetMsg()

If $nmsg = $GUI_EVENT_CLOSE Then ExitLoop

;;; connect part:
$b = 0
While 1
If $nMsg = $butt[$b] Then
If GUICtrlRead($butt[$b]) = "Connect"&$b Then
$ConnectedSocket[$b] = _SSHConnect(GUICtrlRead($input1),GUICtrlRead($input2))
If $ConnectedSocket[$b] = 0 Then
MsgBox(0,"Erreur", "Impossible de ce connecter!!")
ConsoleWrite("nb config:"&$_nbconf&@CRLF)
ConsoleWrite("nb config:"&$_nbconf&@CRLF)

;;; send part:
If $nMsg = $butt2 Then
$ret = _SSHSend( $ConnectedSocket[$b] , GUICtrlRead($input3)&@crlf)

;;; receive part:
$recv = _SSHRecv( $ConnectedSocket[$b])
If $recv <> "" Then
GUICtrlSetData($edit, GUICtrlRead($edit) & $recv )
GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0)
$b += 1
If $b = UBound($butt) Then ExitLoop




Func DisplayArray($array)
$i = 0
$j = 0
if UBound($array,1) = 0 Then Return
While 1
ConsoleWrite("(["&UBound($array,1)&"]["&UBound($array,2)&"]) ")
While 1
ConsoleWrite("["&$j&"]"&$array[$i][$j]&" ")
$j += 1
if UBound($array,2)<=$j Then ExitLoop
$i += 1
$j = 0
if UBound($array,1)<=$i Then ExitLoop


I join with UDF version of modified putty myself.  :-) LoL

but, it is not used with the UDF, it is included in the UDF.


putty-04012015- 92453+lic.zip


Edited by jeanphile
Added code tags
  • Like 1

Share this post

Link to post
Share on other sites

Thanks for sharing.


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API Forum Rules *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-10-31

Share this post

Link to post
Share on other sites

Thanks for sharing~`


Share this post

Link to post
Share on other sites

A nice share, the only question i have:Is there a way to turn off the automatic password responder after logging on?
I have to fill in a secondary password to enable advanced level and this password is not the same as the logon-password.


Share this post

Link to post
Share on other sites

Dear fellow citizen.
There are at least a bug:  

Impossible de ce connecté!!     >>> Impossible de se connecter !!
Commande a envoyé:   >> Commande à envoyer

Ce sera déjà plus "propre" ;)

Kind regards

  • Like 1

Share this post

Link to post
Share on other sites

A nice share, the only question i have:Is there a way to turn off the automatic password responder after logging on?
I have to fill in a secondary password to enable advanced level and this password is not the same as the logon-password.


Yes, simply do not fill in the login and password.

Share this post

Link to post
Share on other sites

Yes, simply do not fill in the login and password.

I did that, however that unfortunately does not work. After filling in the login data manually, the password will be reused whenever the phrase "Password:" comes back in the buffer. Hence the question how do i toggle off the auto responder completely so that nothing is triggered for that phrase.

login as: Using keyboard-interactive authentication.

Router line 2 

% Access denied



Share this post

Link to post
Share on other sites
Hi lbsl;
Your problem is the operation of plink.
_SSHParametreSet ("login", GUICtrlRead ($input4))
_SSHParametreSet ("passwd", GUICtrlRead ($input5))
When you fills both of these parameters, plink will parsed messages login and password and answer. It cannot be the prevented.


to avoid the problem, should you send from the code the login and the password.


viewing I modified the example so that plink manages more authentication.
excuse my English, I'm French!


Share this post

Link to post
Share on other sites

Do you think using this UDF and a POP3 UDF (or IMAP) I'd be able to retrieve GMail messages? 

Share this post

Link to post
Share on other sites
Hi lewisg,
No, the ssl encryption is not implemented in the same way.

Messaging, to do with stunnel (also not too difficult to manage with Autoit)


Share this post

Link to post
Share on other sites

very nice. if this udf can turn on ssh tunnel, i will be very powerful.

Share this post

Link to post
Share on other sites

Hi Chamlien,

It can, but it's a little more difficult to set up :-)


Single Port Redirerction

$__PortForwardings = "L8080="

Dynamic port forwarding (used for example with Proxifier)

$__PortForwardings = "D3128="

Edited by JiBe

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

  • Similar Content

    • caramen
      By caramen
      I watched _OL_ItemSend&_OL_ItemFind&_OL_ItemCreate in OutlookEx UDF but hmmm
      Since it use the test environnement i cant get the orders of the mail creation
      Can someone make me win some time of reading all exemples script and lead me how to do one ?
      That whould be lovely.
    • Tersion
      By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip  (12 downloads previously)
      (I have now completed all the functions I intended to. My next update will be a big improvement, bringing things more inline with my latest INItoSQL DB program changes.)
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • Blueman
      By Blueman
      Hey Guys,

      I have a (i think) simple question, but i can't seem to get the answer though the help-files.
      Hope that you can help me with this issue.
      - I am opening a SSH Connection with the following function
      Func _Connect($session,$usr,$pass) $exec = @ScriptDir & "\PLINK.EXE" If Not FileExists($exec) Then _Err("PLINK.EXE Not Found!",0) $pid = Run($exec & " -load " & $session & " -l " & $usr & " -pw " & $pass, @ScriptDir, @SW_HIDE, 0x1 + 0x8) ;Run SSH.EXE If Not $pid Then _Err("Failed to connect",0) $currentpid = $pid ;$rtn = _Read($pid) ;Check for Login Success - Prompt ;MsgBox(48,"","1") ;sleep(5000) ;Wait for connection Return $pid EndFunc - This will connect to a CMS Server with a vt100 interface where a dynamic report is generated every 20 seconds.
      - Then i will read the contents with the following Function
      Func _Read($pid) $SSHREADTIMEOUT = 0 If Not $pid Then Return -1 Local $dataA Local $dataB Do $SSHREADTIMEOUT += 1 $dataB = $dataA sleep(100) $dataA &= StdOutRead($pid) If @error Then ExitLoop Until ($dataB = $dataA And $dataA And $dataB) OR $SSHREADTIMEOUT == 50 Return $dataA EndFunc This all goes correctly, but i can only read the contents once.
      When i try to read the contents again i get nothing.
      Maybe because the CMS isn't changing, but the values in the report is changing every 20 seconds.
      I need to somehow read al of the contents every time i perform a Read action, but how?
      Yes, i can use it in a While loop, but also then i get nothing or a small line of text and not the whole report.
      Any Idea?
      Thanks Guys!
      I have fixed the problem by changing the terminal session to a vt220 session.
      The only problem now is that i want to send the: "Data link escape" command and that is something i cannot fix,.
      I have tried;
      StdinWrite($Pid,Hex(0x10)) StdinWrite($Pid,Chr(16)) StdinWrite($Pid,{DLE}) But nothing seems to work.  
      -- Edit-2 --
      Guys, fixed that too!
      Forgot to add the number '5' to actually execute the assignment.
      So fixed it by using;
      StdinWrite($Pid,Chr(16)) StdinWrite($Pid,"5")
      Thanks for reading with me
    • xtcislove
      By xtcislove
      as a start in Autoit i tried something i was missing since im using Autoit. 

      I build a custom MessageBox which has a large amount of custom options and which scales its size on the parameters you set. 

      Aviable Settings:
      -Unlimited Buttons
      -Text Color (Buttons, Text)

      -Background Color (Msgbox, Buttons, Label) 

      -Button Timeout
      -Autoclose Timeout
      -Icon (Default, No Icon, Custom)

      -Label/ Button Style. 

      I tried to keep this as close as i could to a Msgbox i was used too on my batch times.

      After i was ready i realised, @Melba23 probably build a way better msgbox which would have suit my needs enterly, anyway thanks to @Melba23 because i use his Stringsize UDF. 

      local $Message = _sMsgBox("Test", 6, "Continue?") if @extended <> -1 Then MsgBox(0, @extended, $Message&" Button pressed")