Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Coffee corner » FtpClient equivalent for SFTP
FtpClient equivalent for SFTP [message #60452] Wed, 07 February 2024 12:44 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

My program has an FtpClient class that moved file to the user server.
Now his server use SFTP protocol and he reports my program is unable to work.

I have not found a SFtpClient (do we have one?). However I found the package SFtpFileSel.
I guess I should use
SFtp sftp(session);

sftp.MakeDir()
to create a directory

sftp.SaveFile()
to transfer file

to change directory
sftp.OpenDir()

Is all this correct?
The SFtp class will work even with normal FTP protocol?

Thanks,
Luigi
Re: FtpClient equivalent for SFTP [message #60453 is a reply to message #60452] Wed, 07 February 2024 13:25 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello Luigi,

SFtp class is part of SSH package (is in uppsrc/Core, it has its API doc as Topic++ and examples in the reference examples section (SshBasics & SFtpFileSel).

You cannot use SSH package with plain FTP protocol, as they are completely different.

However, there are also additional an alternative FTP class here, which is arguably more advanced than the default one in uppsrc.

If you need additional example on SSH and FTP, see the upp-components/examples section.


If you need any more help, let me know.

Best regards,
Oblivion


[Updated on: Wed, 07 February 2024 13:27]

Report message to a moderator

Re: FtpClient equivalent for SFTP [message #60454 is a reply to message #60453] Wed, 07 February 2024 22:07 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Oblivion wrote on Wed, 07 February 2024 13:25

However, there are also additional an alternative FTP class here, which is arguably more advanced than the default one in uppsrc.


Thank you Oblivion.

From my previous questions you have understood how confused I am Smile . I have no experience in SFTP.

Let me state better my problem.

1. on a local folder there are some cripted files;
2. I connect to the user server with FtpClient;
3. then each file is decrypted and transfered in some folder of the user's server.

Now that his server switched to SFTP (no FTPS) is there some way/class that can help me to do the same?
(I cannot decrypt those file on the local folder).

Thanks,
Luigi
Re: FtpClient equivalent for SFTP [message #60459 is a reply to message #60454] Sat, 10 February 2024 19:30 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello Luigi,

Sorry I couldn't reply earlier.

There are several ways to transfer a file to a remote host.

One of the basic examples could be as follows:

#include <Core/Core.h>
#include <Core/SSH/SSH.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	SshSession session;
	FileIn fi("/local/files/myfile");
	if(fi && session.Compression().Connect("user:password@address:port_number")) {
		SFtp sftp(session);
		sftp.WhenProgress = [](int64 done,int64 total) { Cout() << done << " / " << total << "\n"; return false; };
		if(!sftp.SaveFile("/remote/files/myfile", fi))
			Cout() << "File transfer failed: " << sftp.GetErrorDesc() << "\n";
		return;
	}
	if(session.IsError())
		Cout() << session.GetErrorDesc() << "\n";
}




Note that this example code does not handle the private and public keys, or other mechanism but the examples I provided via the link of my first post can help you. Especially the SftpBrowser. It can open connections with public/private key, and upload files.

Best regards,
Oblivion


Re: FtpClient equivalent for SFTP [message #60462 is a reply to message #60459] Mon, 12 February 2024 22:36 Go to previous message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Oblivion wrote on Sat, 10 February 2024 19:30

Note that this example code does not handle the private and public keys, or other mechanism but the examples I provided via the link of my first post can help you. Especially the SftpBrowser. It can open connections with public/private key, and upload files.

Best regards,
Oblivion


Thanks a lot.
I'll study your example.

Luigi
Previous Topic: Shot my leg again...
Next Topic: Linux Fedora 39
Goto Forum:
  


Current Time: Sun Apr 28 02:41:29 CEST 2024

Total time taken to generate the page: 3.04308 seconds