Android Question [Library - JSch] and server freeSSHd v1.3.1

T201016

Active Member
Licensed User
Hello all!
I would like to devote a moment to the FreeSSHd 1.3.1 server
and the JSch open source project library (1.10 and 1.30)

Well, after switching from the old version of the server to the newer 1.3.1, I can not properly connect to the server
from any Android. I do everything according to various examples at the Forum.
Interestingly, the WinSCP Client works under my configuration correctly, accepts the keys,
authorization goes without a problem.

And I'm in trouble with Android. I suppose I'm doing something wrong with a private RSA key on Android.
SFTP I initiate by SFTP1.Initialize ( "SFTP1", "username", "password", "ip", 22)

My question to those who know each other:
- Has anyone already used this server and knows how to create the keys one by one, and where they should be
find on server and on Android?
I admit that I already installed this server in the old version, and everything worked well.
Now even the order of confirmation does not work:

B4X:
Sub SFTP1_PromptYesNo (Message As String)
Dim res As Int
res = Msgbox2 (Message, "?", "Yes", "", "No", Null)
SFTP1.SetPromptResult (res = DialogResponse.POSITIVE)
'SFTP1.SetPromptResult (True)' ('Fingerprint question passed.')
End Sub

Thank you in advance for a hint.

B4X:
Sub Process_Globals
End Sub

Sub Globals
    Dim SFTP1 As SFtp
    Dim RAFile As RandomAccessFile
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim Inhalt As String
    If FirstTime Then
        SFTP1.Initialize("SFTP1","username","password","ip",22)
        SFTP1.SetKnownHostsStore(File.DirInternal , "hosts.txt") '-------------> here I am pointing to a different path and name than in the example.
        ToastMessageShow("SFTP initialized.",True)
    End If
    GetIPFile
    Inhalt = ReadFile
    Msgbox(Inhalt& " Bytes read.","")
    DeleteFile
    SFTP1.Close
    ToastMessageShow("CLOSE", True)
    File.Delete(File.DirInternal , "hosts.txt")
    Msgbox("THE END","")
End Sub

Sub Activity_Resume
    SFTP1.Activity_Resume
End Sub

Sub SFTP1_PromptYesNo (Message As String)
    Dim res As Int
    res = Msgbox2(Message,"?", "Yes","","No", Null)
    SFTP1.SetPromptResult(res = DialogResponse.POSITIVE)
'   SFTP1.SetPromptResult(True) '("Fingerprint question passed.")
End Sub

Sub GetIPFile
    SFTP1.DownloadFile("/tmp/serwer.txt",File.DirRootExternal,"serwer.txt") '("Download requested.")
End Sub

Sub ReadFile As String
Dim a As String
Dim i As Long
    RAFile.Initialize(File.DirRootExternal,"serwer.txt",True)
    a="":i=0
    Do While i<>RAFile.Size
        a = a & Chr(RAFile.ReadUnsignedByte(i))
        i=i+1
    Loop
'    Log(i & " Bytes read.")
    RAFile.Close
    Return a
End Sub

Sub DeleteFile
    File.Delete(File.DirRootExternal,"serwer.txt") '("internal file deleted.")
End Sub

Sub SFTP1_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
  Dim s As String
  s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
  If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
  ToastMessageShow(s,True)
End Sub

Sub SFTP1_DownloadCompleted (ServerPath As String, Success As Boolean)
    ToastMessageShow(ServerPath & ", Success=" & Success, True)
    If Success = False Then
        Msgbox(LastException.Message,"Download Completed = False")
    End If
End Sub
 
Last edited:

T201016

Active Member
Licensed User
It is possible that your server uses a different version of SSH that is not supported by the library. What happens when you try to connect?
Parameters:
Type of key to generate: SSH-2RSA
Number of bits in a generated key: 2048

SFTP-3 file transfer protocol
SSH-2 cryptography protocol (implementation of WeOnlyDo 2.4.3)

I try to authenticate connections using Pagent
and the identifying parameter is the private key file (Putty format).

I understand that changing the host key should result in the expected display
in this case, the warning message on Android, but does not cause (!?)
However, it works correctly on the computer:
I get a message with similar content - "The host server key does not match the WinSCP cache key."
and I have to choose (update / add key, disconnect)
 
Top