Jump to content

Search the Community

Showing results for tags 'ssh'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 5 results

  1. Hello everyone, I've created a UDF for basic communication with SSH servers. I know there is already such a UDF, but I wasn't satisfied with it for my purpose, so I created a new one. This UDF also acts as a wrapper for the plink executable. Its essential functions are _SSHConnect, _SSHSend, _SSHRecv and _SSHCloseSocket. It does support multiple simultaneous connections and aims to be pretty robust. Feel free to share your opinions Two of the included examples use a slightly modified version of Vintage Terminal by @Chimp Download The download includes ssh.au3 (UDF), plink.exe (necessary), vintage terminal and code examples: Version 1.0.1 - fixed rare _SSHConnect bug where "ssh-host-key prompt" was not answered SSH UDF 1.0.1.zip
  2. Hi all. Today I would like to introduce the beginning of the UDF. How to get started: http://winscp.net/eng/docs/library http://winscp.net/eng/docs/library_install Original readme_automation.txt: now I have only one function (standard FTP on standard port) to show the future possibilities: Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Const Enum _ $__eWSCP_SO_Protocol_Sftp, _ $__eWSCP_SO_Protocol_Scp, _ $__eWSCP_SO_Protocol_Ftp Const Enum _ $__eWSCP_TO_TransferMode_Binary, _ $__eWSCP_TO_TransferMode_Ascii, _ $__eWSCP_TO_TransferMode_Automatic Example_PutFile('YOUR FTP HOST NAME', 'YOUR USER NAME', 'YOUR PASSWORD') Func Example_PutFile($sHostName, $sUserName, $sPassword) Local $sFileFullPath = StringReplace(@ScriptFullPath, '\', '\\') Local $sFilesToPut = StringReplace(@ScriptDir & '\*.au3', '\', '\\') ; based on: ; http://winscp.net/eng/docs/library_com_wsh#vbscript Local $oSessionOptions = ObjCreate("WinSCP.SessionOptions"); With $oSessionOptions .Protocol = $__eWSCP_SO_Protocol_Ftp .HostName = $sHostName; .UserName = $sUserName; .Password = $sPassword; ; below not jet tested ; .SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" EndWith Local $oSession = ObjCreate("WinSCP.Session"); With $oSession ; Connect: Open sesion with defined options .Open($oSessionOptions); ; Set TransferOptions Local $oTransferOptions = ObjCreate("WinSCP.TransferOptions") $oTransferOptions.TransferMode = $__eWSCP_TO_TransferMode_Binary ; Upload files: put @ScriptFullPath to the ROOT directory Local $oTransferResult = .PutFiles($sFilesToPut, '/'); ; Throw on any error $oTransferResult.Check ; Print results For $oTransfer In $oTransferResult.Transfers ConsoleWrite("Upload of " & $oTransfer.FileName & " succeeded" & @CRLF) Next ;' Disconnect, clean up .Dispose() EndWith ; CleanUp $oSession = '' $oSessionOptions = '' EndFunc ;==>Example_PutFile Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc EDIT: 2014-06-20 04:47 - script changed
  3. 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. Example: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.4.0 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 #include #include #include #include #include "SSH_udf.au3" _SSHStartup() 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) GUICtrlSetState($butt2,$GUI_DISABLE) $edit = GUICtrlCreateEdit("",10,130,530,260,$WS_VSCROLL);,$WS_DISABLED)) GUISetState() 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 _SSHParametreSet("yesall",GUICtrlRead($Checkbox)) _SSHParametreSet("protocol",GUICtrlRead($input6)) _SSHParametreSet("login",GUICtrlRead($input4)) _SSHParametreSet("passwd",GUICtrlRead($input5)) $ConnectedSocket[$b] = _SSHConnect(GUICtrlRead($input1),GUICtrlRead($input2)) If $ConnectedSocket[$b] = 0 Then MsgBox(0,"Erreur", "Impossible de ce connecter!!") Else GUICtrlSetData($butt[$b],"Close"&$b GUICtrlSetState($butt2,$GUI_ENABLE) EndIf DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) Else _SSHCloseSocket($ConnectedSocket[$b]) GUICtrlSetData($butt[$b],"Connect"&$b GUICtrlSetState($butt2,$GUI_DISABLE) DisplayArray($_config) ConsoleWrite("nb config:"&$_nbconf&@CRLF) EndIf EndIf ;;; send part: If $nMsg = $butt2 Then $ret = _SSHSend( $ConnectedSocket[$b] , GUICtrlRead($input3)&@crlf) GUICtrlSetData($input3,"") GUICtrlSetState($input3,$GUI_FOCUS) EndIf ;;; receive part: $recv = _SSHRecv( $ConnectedSocket[$b]) If $recv <> "" Then GUICtrlSetData($edit, GUICtrlRead($edit) & $recv ) EndIf GUICtrlSendMsg($edit, $EM_SCROLL, $SB_PAGEDOWN, 0) $b += 1 If $b = UBound($butt) Then ExitLoop WEnd WEnd _SSHCloseSocket($ConnectedSocket) _SSHShutdown() Exit 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 WEnd ConsoleWrite(@CRLF) $i += 1 $j = 0 if UBound($array,1)<=$i Then ExitLoop WEnd EndFunc 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 ssh_udf.zip New version (contains the latest version of plink (0.74) edited by http://jakub.kotrla.net/putty/) ssh_udf-v2.zip Same as the v2 but supports all putty/plink settings ssh_udf-v2.1.zip
  4. 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! --Edit-- 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
  5. Hello, I'm trying to make a SSH connection using TCP on port 22. But the only thing i get is "protocol mismatch". And yes, i have read the RFC4251 (http://www.ietf.org/rfc/rfc4251.txt) but i'm not quite sure on how to exchange the public and private keys using TCPsend... The only "normal" response from the server i get is SSH-1.99-OpenSSH_3.4p1 , after that i get (10053) Software caused connection abort. Is there any UDF available for SSH connections? or anyone who made a SSH connection using autoit? Either way, any help is greatly appreciated. Thanks in advance!
×
×
  • Create New...