My vitual machine (drived by CentOS) IP is 192.168.1.114
It can be successfully connected using SecureCRT and FileZila.
I try to use Curl to implement file uploading and downloading,

curl --ftp-ssl 

It doesn't work and there is no avaliable information on offical site.
Who can tell me how to do next?Much thanks!

Dani AI

Generated

Quick diagnosis and the root cause: the command you tried used FTP/FTPS options, but SFTP is a different protocol (it runs over SSH, normally on port 22). Curl speaks SFTP only when used with the sftp:// URL scheme (and when the curl binary was built with an SSH backend such as libssh2). That means switching from ftp:// plus --ftp-ssl to sftp:// is necessary if the server is running SSH/SFTP. (jscape.com)

Concrete curl examples (replace username and paths as needed). Download a remote file (save with remote name):

curl -u username sftp://192.168.1.114/path/to/remote-file -O

Upload a local file (use remote directory; trailing slash appends local filename):

curl -T ./localfile -u username sftp://192.168.1.114/remote/dir/

Key-based auth (private key file):

curl --key ~/.ssh/id_rsa -u username sftp://192.168.1.114/remote/file

(The -T/upload behavior and the sftp examples are documented in the curl docs.) (ec.haxx.se)

Auth and path gotchas: curl will try public-key auth first if a key is available; use --key (and --pass if the key is passphrase-protected) or supply credentials. In some situations putting username:password in the URL forces password auth when -u alone does not; that workaround is documented in user reports. Also note sftp/scp URLs are treated as absolute paths on the server — use /~/ for paths relative to the account home. (curl.se)

Troubleshooting steps to try now (echoing ' good suggestion to get verbose output): 1) run curl --version and confirm sftp appears in the Protocols list; 2) try a simple download/upload above with -v to see which auth methods the server advertises; 3) if sftp is missing from your curl, install a package/build with libssh2 support or use the OpenSSH sftp client instead. If you paste -v output when asking for more help, redact passwords. (curl.se)

References: curl tutorial/manual (sftp usage) — https://curl.se/docs/tutorial.html. Curl uploads doc (-T) — https://ec.haxx.se/usingcurl/uploads.html. SFTP vs FTPS overview — https://www.jscape.com/blog/understanding-key-differences-between-ftp-ftps-and-sftp.

Recommended Answers

All 2 Replies

anybody?

I don't know much about it, but there are many links about this. This one for example looks good . It seems to me that you should at least try the -v option to get debugging information if it fails.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.