Windows, Shell, SSH, stdin, and Xojo

Have you reached out to Xojo Tech Support?

Have you tried these variations?
Shell.Execute “powershell.exe ssh test@test…”
Shell.Execute “cmd.exe /C ssh test@test…”

I have not yet, I was hoping I’d missed something simple! I may head down that route tomorrow.

I have just tested these to find they both give me the original message of “Pseudo-terminal will not be allocated because stdin is not a terminal.” :frowning:

Tim / William,

I usually pass additional params to ignore user profile and execution policy on Windows - unless I do so - commands won’t execute.

sh.Execute("powershell.exe -NoProfile -ExecutionPolicy Bypass

If you just need a DataAvailable handler, I could work on that.
Maybe even an example using it.

I added DataAvailable event and made a GUI example for next release:

1 Like

blog post: SSH Terminal example for Xojo

@Tim_Parnell
Doing a few searches, the problem seems to be that you wouldn’t be able to enter the password in the shell. If this is the problem, are you able to use key pairs for authentication?

That’s how we solved this for an internal need on macOS. Just throwing it out there. I can try it out when I get to my desk today.

The problem is that we’re not even there yet. I either get the above message, or no DataAvailable. Christian’s terminal window project should be helpful, so I think I’m just going to wait on the plugin for this.

1 Like

Tim,

Whilst Christian has added this functionality to MBS (and I admire/applaud his zeal, agility, and great customer service in doing so), alternatives configurations/solutions remain available to you (and others).

Three plugin alternatives (or additional solutions):

  1. configure password-less (as in stored password) access for SSH on Windows 10 (passthru);
  2. install and use sshpass on Windows 10
    sshpass -p your_password ssh user@hostname
  3. use plink ```
    plink your_username@yourhost -pw your_password
Some references

https://superuser.com/questions/1433917/windows-10-ssh-client-password-less-access
https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password
https://stackoverflow.com/questions/37243087/how-to-install-sshpass-on-windows-through-cygwin

Example to use SSH (plink.exe) from putty application with Xojo:

Putty Open Source Licence: https://www.chiark.greenend.org.uk/~sgtatham/putty/licence.html

This code was written with Xojo 2016 https://pastebin.com/v4iR8c28

  1. Create a working folder: Test-shell-interactive

  2. Create a new folder in Test-shell-interactive named: ssh

  3. Download 64bit version of plink.exe from https://the.earth.li/~sgtatham/putty/latest/w64/plink.exe

(Main site: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html )

  1. Copy plink.exe into folder ssh (…\Test-shell-interactive\ssh)

  2. cut and paste the XML code from https://pastebin.com/v4iR8c28 into file named: shell-interactive-1.xojo_xml_project

  3. Load the file in Xojo

First time you open the file shell-interactive-1.xojo_xml_project with Xojo, a Resolve Project Issues window appears. Click on the check box plink and select resolve. Then browse and select plink.exe in subfolder ssh (…\Test-shell-interactive\ssh)

Buttons:

Most of the buttons speaks for it self.

Login button you only use once and when you are finished using the remote shell, it’s very important you press the “Close Shell” button.

The Close Shell button send a chr(3) to the remote host and will close the shell on the remote host. If you close the application without first execute Shell1.WriteLine(chr(3)) to the remote server. The shell will stays active, and next time you do a remote login another shell is created.

3 Likes

I’ve been working on an open source binding to libssh2: https://github.com/charonn0/RB-libssh2

It’s still not 100% complete (in particular there’s no DataAvailable event) but it is usable with password, keys, or agent based authenticaction:

  Dim sh As SSH.Channel = SSH.OpenChannel("ssh://user:password@public.example.com/")
  Call sh.Execute("uptime")
  Dim result As String
  Do Until sh.EOF
    result = result + sh.Read(1024, 0)
  Loop
  sh.Close
1 Like

New plugins uploaded, see

1 Like

Could you write up some kind of doc “How to build libssh2 for this library” ? Trying to figure this out on my own has me feeling really defeated.

I asked Chrsitan to include a SFTP stream for his libssh2 wrapper, but have been “wish list”-ed which means I can’t use MBS.

I wish I could! Instead I use the pre-built DLL distributed by the libcurl project, available here.

Hey, we do have SFTP file transfer in the CURLSMBS class already!

P.S. You also need libcrypto-1_1.dll, which is part of OpenSSL.

https://curl.haxx.se/windows/dl-7.72.0_5/openssl-1.1.1h_5-win32-mingw.zip

I’d have to write two authentication systems, and handle two different types of classes to use MBS. SFTP is SSH, so I shouldn’t have to.

@Andrew_Lambert’s library won’t make me write it twice. I’d love to use MBS, but you put what I need on “wish list” so I can’t.

(It’s not you, it’s me. I’ve been rewriting this thing since April and am quite tired of doing so.)

@Tim_Parnell (SFTP stream)
You should be able use the pscp.exe from putty for this https://the.earth.li/~sgtatham/putty/latest/w64/pscp.exe via a shell

1 Like