03 - Open Source (EN)03f - Tools Open Source (EN)

Open Source – Lftp – Not just ftp and sftp

Last Updated on 1 May 2020 by Roberto De Pedrini

The opening of IBM i to the Open Source world allows you to install languages and tools that simplify the processes of our business applications.

For example, a typical case is that of SFTP which has replaced the old FTP in various corporate data exchange processes (shipments with couriers, border ships, etc.).

If we have to exchange files with SFTP, we do not always have the possibility of making clients and servers “trusted” through an exchange of RSA keys which guarantee secure communication without having to exchange passwords every time.

If we must continue to use the user and password, batch script management is not as simple as we are used to doing with FTP and we have to resort to utilities (always from the open source world) such as Expect: we always talked about it on this blog a few months ago : SFTP with password (no SSH key authentication).

An interesting alternative, which opens IBM i in addition to ftp and sftp also to other protocols such as torrent, is “LFTP”

Lftp allows you to create scripts similar to those we used with FTP … with user and password in the script itself, losing something from an internal security point of view for the benefit of simplicity, also opening up a world of new possibilities such as SFTP, TORRENT, HTTP, upload – download bandwidth control, resumption of downloads in case of outage, mirror functionality (rsync-style) between client and server directories.

In conclusion … small, but really powerful, open source package: let’s see how to install and use it in the IBM i environment

From QSH environment, or better, with an SSH terminal connected to the IBM i PASE environment:

bash-4.4 $ yum install lftp

We follow the installation steps and start testing it on a public SFTP server and download an entire directory of the server into our own IFS directory.

Public SFTP Server: demo.wftpserver.com
Port: 2222
User: demo-user
Password: demo-user

Now create a new directory on our IFS
bash-4.4 $ mkdir / home / faq400 / wftp_download

Then we can download to the remote directory with this command with an integrated script:

bash-4.4 $ lftp -c "set ssl: verify-certificate no; set sftp: auto-confirm yes; open sftp: // demo-user: demo-user@demo.wftpserver.com: 2222; lcd / home / faq400 / wftp_download; cd download; mget *; quit "

In the above case, we download a whole directory. If it is a periodic operation it might make sense to reason “incrementally” by going to download only the files modified since the last download:

bash-4.4 $ lftp -c "set ssl: verify-certificate no; set sftp: auto-confirm yes; open sftp: // demo-user: demo-user@demo.wftpserver.com: 2222; mirror --verbose - -use-pget-n = 8 -c / home / faq400 / download / pdf / 2020 / testmirror /; quit "

LFTP options are really many … here are some examples:

mget -c to continue interrupted download

set net: limit-rate 0: 512000 to limit upload bandwidth
set net: limit-total-rate 3M: 500K to limit download and upload

lftp -e 'pget -c -n 5 / path / to / file' sftp: // username @ server Multiparts transfer

LFTP, a really interesting open source package for file transfer management also in IBM i environment

Related Posts
Alternative to OVRDBF in F specifications (dcl-f free)

It is not new to RPG but every now and then it is useful to remember that if we want Read more

ILE Debugger (STRDBG) and Screen Size

When we use the 5250 ILE Debugger interface (waiting for a Debugger for VsCode or a faster version of the Read more

Check Larger Files (Tables) in a library list

Suppose we want to keep files under control (we should get used to calling them Tables, like the rest of Read more

Security pills: Check User with the default password

I welcome Steve Pitcher's suggestion from this Linkedin Post: a simple SQL statement to get the list of users with Read more

--- Roberto De Pedrini Faq400.com
About author

Founder of Faq400 Srl, IBM Champion, creator of Faq400.com and blog.faq400.com web sites. RPG developer since I was wearing shorts, strong IBM i supporter, I have always tried to share my knowledge with others through forums, events and courses. Now, with my company Faq400 Srl, I help companies to make the most of this great platform IBM i.

1 Comment

Leave a Reply

Your email address will not be published.