SSH/Telnet control

Does anyone know of an SSH/telnet/terminal plugin for Xojo? I want to write an application to automate logging in to network devices (routers, firewalls, etc.) and execute commands. There are several .NET ActiveX/COM controls from companies like WeOnlyDo, Dart and so on to accomplish this but none for Xojo. I do not want to use a shell program such as the OS SSH and telnet functions.

I’ve been a VB.Net programmer for years and have recently started using it again simply for lack of third-party controls for Xojo. I really do like programming with Xojo and I love the fact that it creates stand-alone applications but the lack of third-party support has stopped me more than once.

Any pointers in the right direction would be appreciated.

Alex Restrepo had a Telnet project in his collection, it dates from around 2005 but probably still works.

It should
I just opened that code in Xojo
Not sure its posted publicly anywhere

You may want to ask Kem Tekinay for his SudoShell class (www.mactechnologies.com)

Have a look on this one: http://www.justaddsoftware.net/RealSoftware_files/SSHShellExample.rbp

One very important issue. You should never use telnet if you can avoid it, as all communication is unencrypted. And these days all new firewalls supports SSH.

Chilkat Software has an active-x component for Windows OS. I use their .net component in a couple of projects. If I remember correctly a couple of years ago I was able to use it with RS.

How To Use WinSCP To Send SSH (Secure Shell) Commands

I just realized it’s possible to use winzip with activex.

Download:

  1. Installation package: http://winscp.net/download/winscp517setup.exe

  2. .NET assembly?/?COM library http://winscp.net/download/winscp517automation.zip
    (copy WinScp.dll to location of your installed winscp application and Follow the readme_automation.txt file )

Right now I don’t have much time to write a better example. But with the below code I manage to create an empty file on my server.

  Dim sessionOptions As OLEObject
  Dim Session As OLEObject
  
  sessionOptions = New OLEObject("WinSCP.SessionOptions")
  
  //sessionOptions.Protocol = Protocol.Sftp  // Xojo OleObject don't support enum.
  sessionOptions.Protocol = 0  // RS Oleobject don't support enum  I tried with different numbers and this one works.
  
  
  sessionOptions.HostName = "MyHostName"
  sessionOptions.UserName = "MyUserName"
  sessionOptions.Password = "MyPassword"
  sessionOptions.SshHostKeyFingerprint = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"  // See http://winscp.net/eng/docs/faq_script_hostkey
  
  session = new OLEObject("WinSCP.Session")
  
  session.Open(sessionOptions)
    
  session.ExecuteCommand("/bin/touch /tmp/MyNewFile.txt")

  exception err as oleexception
    msgbox err.message

You can obtain the rsa finger print by invoke following command on your SSH server:
ssh-keygen -lf <file-path-to-rsa_key.pub>

Example:
ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub

Any examples of how to transfer a file from local to remote via ssh using this example ?

SFTP Example:

Here is a simple example howto upload multiple files from winscp’s Portable executables.

Download:

  1. Portable executables: http://winscp.net/download/winscp517.zip

  2. .NET assembly?/?COM library http://winscp.net/download/winscp517automation.zip
    (copy WinScp.dll to location of your installed winscp application and Follow the readme_automation.txt file )

[code]
Dim sessionOptions As OLEObject
Dim Session As OLEObject

sessionOptions = New OLEObject(“WinSCP.SessionOptions”)

//sessionOptions.Protocol = Protocol.Sftp // Xojo OleObject don’t support enum.
sessionOptions.Protocol = 0 // RS Oleobject don’t support enum I tried with different numbers and this one works.

sessionOptions.HostName = “MyHostName”
sessionOptions.UserName = “MyUserName”
sessionOptions.Password = “MyPassword”
sessionOptions.SshHostKeyFingerprint = “ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx” // See http://winscp.net/eng/docs/faq_script_hostkey

session = new OLEObject(“WinSCP.Session”)

session.Open(sessionOptions)

// Copy files from windows to a Linux platform
session.PutFiles(“C:\\temp\\XOJO\\*”, “/tmp/XOJO/”, false) //When set to true, deletes source local file(s) after transfer.

//more info about commands see http://winscp.net/eng/docs/library_session#methods

exception err as oleexception
msgbox err.message[/code]

You can use my TELNET class I wrote. https://forum.xojo.com/6669-my-telnet-class-for-xojo/p1#p46561

if your class is not on the third party plugins/controls page of the docs, you should get Paul to add it.

Sorry Mike,

But in the real world Telnet is dead. SSH is king.
On Mac OS X you can link into OpenSSH but on Windows you are out of luck.
Anyone has written a x-plat class/plugin for this?

Robert trust me I do know :slight_smile: However I am writing apps to connect to devices that do not have SSH enabled. Many times people may still need a TELNET class for Xojo at some point :slight_smile:

Thanks!

Fair enough :slight_smile:

Do you know perhaps if there is a cross-platform SSH class/plugin for Xojo? I looked around but couldn’t find it.

Unfortunately not yet. Kem Tekinay wrote an interactive shell for ssh, but everything I have seen so far people are using the shell for ssh. That is only good for Linux and Mac though.