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: email@example.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: firstname.lastname@example.org: 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--- Roberto De Pedrini Faq400.com