B4A Library [Libary] jkSSH2 - SSH2 communication in B4A


This libary is based on Ganymed SSH-2 libary. An open source java implementation of the SSH2 protocol. The licence is included in the zip file.

This libary currently offers the following SSH2 features:
  • Several authorization methods (None/Username and Password/Key)
  • Execute shell commands on the server.
  • Create local port forwardings.
  • Download files with the scp command.
  • Upload files with the scp command.

  1. Download and unzip the attached zip file.
  2. Copy jkSSH2.jar and jkSSH2.xml to the additional libaries folder.

This example shows how to execute a shell command on the server.
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim SSH2 As jkSSH2
End Sub

Sub Activity_Create(FirstTime As Boolean)
   SSH2.initialize("SSH", "hostname", 22)
   SSH2.authenticateWithPassword("username", "password")

   SSH2.execCommand("uname -a && date && uptime && who", 10)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub SSH_CmdExecuted (Success As Boolean, Result As List, TaskId As Int)
   Log (TaskId)
   If Success Then
      For i=0 To Result.Size-1
         Log(Result.Get(i) & CRLF)
   End If
End Sub

Sub SSH_ConnectionLost (Reason As String)
End Sub


  • jkSSH2.zip
    233.8 KB · Views: 1,038
Last edited:


Licensed User
Longtime User
don´t know. Search the forum.

Stefano Bordini

Licensed User
Longtime User
Hi, i use thi library, and she work correctly in my lan, whit ssh.authenticateWithPassword connet,execute command and SSH_CmdExecuted, but now i want use in vm on google cloud and i need use ssh.authenticateWithKey,the app connect and execute command correctly,but after execute command don't trigger SSH_CmdExecuted.any suggest?