Archived Forum Post

Index of archived forum posts

Question:

Xojo SSH Tunnel

Jun 11 '16 at 17:27

I'm trying to setup an ssh tunnel for a connection to a remote database using Xojo.

I've looked at the examples but I don't see properties in the Xojo autocomplete list for the following:

  m_SSH.SshHostname = m_sHost
  m_SSH.SshPort = m_iPort
  m_SSH.SshLogin = m_sLogin
  m_SSH.SshPassword = m_sPassword

Would anyone have an example for Xojo?

Thanks, Johnny Harris


Answer

This code seems to work:

Function Connect() As Boolean
  mErrorMsg = ""
  ssh.DestHostname = SshHost
  ssh.DestPort = RemotePort
  if ssh.Connect(SshHost, SshPort) then
    if ssh.AuthenticatePw(Username, Password) then
      if ssh.BeginAccepting( LocalPort ) then
        Return true
      else
        mErrorMsg = ssh.LastErrorText
        Return False
      end
    else
      mErrorMsg = ssh.LastErrorText
      Return False
    end
  else
    mErrorMsg = ssh.LastErrorText
    Return False
  end

End Function