B4J Question SFTP to Filezilla Server

Nokia

Active Member
Licensed User
Longtime User
I am trying to send and receive files to and from a FileZilla Server set to SFTP with certificate. I can connect and send a file and receive a file how ever they seem to be blank.

I also get notification that connection was terminated incorrectly.

any body have any ideas of anything else I need to be doing or missing..


B4X:
  Dim oFTP As FTP
  Dim ssltrustmanager As CustomTrustManager

    oFTP.Initialize("iFTP", "lucentalabsportal.com", 3100, <user>, <Password>)
    oFTP.UseSSL = False
    oFTP.UseSSLExplicit = True
    oFTP.PassiveMode = True
    ssltrustmanager.InitializeAcceptAll
    oFTP.SetCustomSSLTrustManager(ssltrustmanager)

Sub btUploadMain_MouseClicked (EventData As MouseEvent)

'three commands I am using
  oFTP.UploadFile(File.DirApp, "LabConnect.ini", True, "/LabConnect.ini")

  oFTP.DownloadFile("/SpaceHolder.txt", True, File.Dirapp, "SpaceHolder.txt")

   oFTP.List("/")

end sub

Sub iFTP_UploadCompleted (ServerPath As String, Success As Boolean)
  Log(ServerPath & ", Success=" & Success)
  If Success = False Then Log(LastException.Message)
End Sub
Sub iFTP_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"
  Log(s)
End Sub
Sub iFTP_DownloadCompleted (ServerPath As String, Success As Boolean)
  Log(ServerPath & ", Success=" & Success)
  If Success = False Then Log(LastException.Message)
End Sub

Sub iFTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
  Log(ServerPath)
  If Success = False Then
  Log(LastException)
  Else
  For i = 0 To Folders.Length - 1
  Log(Folders(i).Name)
  Next
  For i = 0 To Files.Length - 1
  Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
  Next
  End If
End Sub
 
Last edited:

Nokia

Active Member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Don't confuse SFTP with FTPS. SFTP is based on SSH. It will not work with the FTP object.


thanks for the code info..

so what object do I need to be looking at?
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
I have noticed that if I use port 990 (what is open on my firewall) that it connects but does not log me in, but if I use port 3100 what is set in the filezilla server i connect and it shows me logged in but when It starts to transfer I get this message "TLS session of data connection has not resumed or session does not match the control connection"
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
was just reading where I need to have "TLS session resumption". any body know anything about that?
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
This is the coding I have done..

B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
  
   Dim sFTP As SFtp
   Dim msgbox As Msgboxes
   
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.SetFormStyle("UNIFIED")
   MainForm.RootPane.LoadLayout("MainLayout") 'Load the layout file.
   MainForm.Show

   'SFTP object
    sFTP.Initialize("sFTP1", <username>, <password>, <address>, 22)
    sFTP.SetKnownHostsStore(File.Dirapp, "hosts.txt") 'host file is blank
   
End Sub

sub btUploadMain_MouseClicked (EventData As MouseEvent)
         
   sFTP.DownloadFile("/SpaceHolder.txt", File.DirApp, "SpaceHolder.txt")
   
End Sub

Sub sFTP1_PromptYesNo (Message As String)
   Dim res As Int = msgbox.Show2(Message, "FTP","Yes","", "No")
   Log(Message)
   
   Dim b As Boolean = False
   If res = -1 Then b = True
   sFTP.SetPromptResult(b)
   
   'sFTP.SetPromptResult(True)
End Sub
Sub sFTP1_ShowMessage (Message As String)
  Log(Message)
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"
  Log(s)
End Sub
Sub sFTP1_DownloadCompleted (ServerPath As String, Success As Boolean)
  Log(ServerPath & ", Success=" & Success)
  If Success = False Then Log(LastException.Message)
End Sub

all I get is:

(000099)1/11/2016 10:51:27 AM - (not logged in) (173.200.54.114)> Connected on port 22, sending welcome message...
(000099)1/11/2016 10:51:27 AM - (not logged in) (173.200.54.114)> 220-FileZilla Server 0.9.53 beta
(000099)1/11/2016 10:51:27 AM - (not logged in) (173.200.54.114)> 220 Thank you for connecting to secure ftp server.
(000099)1/11/2016 10:51:57 AM - (not logged in) (173.200.54.114)> 421 Kicked by Administrator
(000099)1/11/2016 10:51:57 AM - (not logged in) (173.200.54.114)> disconnected.

I don't get a prompt for the fingerprint. note that it does not even get to the point of being logged in. I have the following libraries:

jCore, jFX, jMsgboxes, jNet, jSch...
 
Upvote 0

Nokia

Active Member
Licensed User
Longtime User
Try to run this code from a B4A app. Does it work?

I think I have figured out the problem, FileZilla server does not support SFTP, the client does but not the server. I guess I go back and use my code for FTP with SSL.. which has it's own set up problems..
 
Upvote 0
Top