Jump to content

Recommended Posts

Posted (edited)

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

  Reveal hidden contents

Download

The download includes ssh.au3 (UDF), plink.exe (necessary), vintage terminal and code examples:

  Reveal hidden contents

Version 1.0.1

- fixed rare _SSHConnect bug where "ssh-host-key prompt" was not answered

SSH UDF 1.0.1.zipFetching info...

 

Edited by p4sCh
added version 1.0.1
Posted
  On 9/30/2021 at 1:07 PM, gcriaco said:

It works fine. Many thanks and compliments!

Expand  

Thank you 😊

  On 10/2/2021 at 7:45 AM, Chimp said:

Hi @p4sCh, good job!

thanks for sharing :)

Expand  

Thanks for providing the vintage terminal. It really took the examples to another level!

You might want to consider to update the original vintage terminal thread with the modified version from this UDF.

It does have some bug fixes, new features and should have noticeable better performance.

  On 10/1/2021 at 3:11 AM, JiBe said:

this UDF SSH - AutoIt Example Scripts - AutoIt Forums (autoitscript.com) support multiple simultaneous connections.

 

Expand  

I know :). And it supports many plink settings which can not be adjusted in this UDF. I had different reasons to make another SSH UDF.

Posted

Hi,

Thanks for sharing but ...

I wonder why you use an external app to create an SSH cleient.

While W10 has this out of the box using the SSH command

usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command]

Which also integrates in Windows Terminal 

https://docs.microsoft.com/en-us/windows/terminal/tutorials/ssh

 

Posted (edited)
  On 10/5/2021 at 7:49 AM, ptrex said:

Hi,

Thanks for sharing but ...

I wonder why you use an external app to create an SSH cleient.

While W10 has this out of the box using the SSH command

Expand  

Just because I didn't knew about this feature 😅
Very interesting, thank you. At the moment I have little time but I consider changing the UDF to use this method primarily or as alternative to plink. Would be nice to drop the additional executable.

Edit: Looks like this command is only available from Win10 (Version 1709+). So on an older OS you would have to use plink instead.

Edited by p4sCh
  • 1 year later...
Posted (edited)

I tried the original SSH UDF and the upgraded v2.1 but I keep getting:
No supported authentication methods available (server sent: publickey)

 

I know I'm using the correct IP/Port User/Pass.

I am using it on Windows 11.  Do I need to have my PPK file anywhere for this to work or something?

 

Edit: Ok... I figured out my issue.  I had to launch pageant to load my ppk file.  Now it is working. 

Edit2: I was also able to add "-i [pathtoPPKfile]" to the $plinkCmd

Which then works without pageant.

Edited by Proph
  • 1 year later...
Posted (edited)

SIMPLE AUTOIT SSH EXAMPLE CODE

I found the ssh UDF libraries to be ridiculously complicated for what is needed. Just use the following as an example. The way the French dude used the socket concept is good. I used that, but spinning out the plink executable every time is overkill. And they always spin out that overly complicated -load wacko config file thing which then always spits the host key question at you for some insane reason. Apparently this is because of using the config. I never found a way around it other than pulling the putty registry host key out by IP and writing it to file each time to make it happy. That all seemed too much... so  I decided to go simple and the following works very well for me.

I am using it to pull data from Linux repositories and VMware ESXi servers all at the same time and doing a comparison to monitor for wasted space in my client's offsite storage repositories sitting in thin files. I spit it to a simple web server I found in Autoit. It all worked for me.

Although trying to get this to work initially baffled me no end. I leave this here for next guy trying to figure how to use ssh with Autoit and pull data from the Linux environment. IT CAN BE DONE AND IT IS EASY. You just have to have the right attitude. I never thought of using plink.exe like this. This is sweet.

You can also easily break this code up a bit and first create socket with plink.exe, then send multiple commands, and pull and spin through the results for what you want, and then close the socket. The socket amazingly is the plink pid I think. Stupefyingly amazing how well it all works.

 

example.au3Fetching info...

Edited by BobMerit

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
×
×
  • Create New...