Wednesday, May 29, 2013

Upload a file to FTPES server using CURL

Security is a major concern when transferring file to another server. Nowdays, most of the file transfer is conducted over SSL which adds extra layer of security by encrypting the data. There are two types of such connections are possible.

1. Explicit over TLS server, which is also called FTPES
2. Implicit over TLS server, which is also called FTPS.

In this article, I will demostrate how to use Linux built-in and very powerful utility CURL to connect with FTPES servers.

Here is an example:

curl -T testfile.txt -k -v --ftp-pasv --disable-epsv --ftp-ssl

Lets break down above example to understand how it works.

The first part
is fairly self explanatory, it invokes the curl command.

We then supply the -T option and the file which we want to upload.
-T testfile.txt

We then add an optional -k switch, which ignores any certificate related error.

the -v just used for verbose output so we can see any error which may occur more easily.

--ftp-pasv forces the connection to be made in passive mode. It connects in Active mode by default.

--ftp-ssl or --ssl tries to use SSL/TLS for the connection. It reverts to normal mode if server does not support SSL/TLS

At last but not least, provide your server's FQDN followed by the directory name.

No comments:

Post a Comment