You are currently on IBM Systems Media’s archival website. Click here to view our new website.

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

sFTP Tips

What you need to know for easy and secure file transfers



 

sFTP in Batch

You can also invoke sFTP in batch with the -b (for batch) parameter. I’ll use a script file that contains commands such as get or put. For example:

put /settle/workfile.txt /incoming/workfile.txt
exit

This script file will send the /settle/workfile.txt file in the IFS to the remote system as file /incoming/workfile.txt, and then exit sFTP. You can invoke the script file in several ways—I use QSH (the QShell environment) and specify the sftp command directly:

QSH CMD('/QOpenSys/usr/bin/sftp -b /Script/put_script.txt
    RMTUSER@commpartner.com')

Verbose Debugging

Sometimes the best of plans don’t do what we planned. A helpful technique to see what exactly is being generated is the -v (or -vv or -vvv) parameter. The number of v’s determine the amount of logging information that will be provided. Using the sFTP command above, we could change it to:

sftp -vvv -b /Script/put_script.txt RMTUSER@commpartner.com

Or, in batch as:

QSH CMD('/QOpenSys/usr/bin/sftp -vvv -b /Script/put_script.txt
    RMTUSER@commpartner.com > /logs/put_logoutput.txt 2>&1')

In the interactive example, the verbose debugging output will be displayed on the screen. In the batch example, the output will be placed in file /logs/put_logoutput.txt. In either case, the output will look something like this:

Connecting to commpartner.com...
OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0.9.7d 17 Mar 2004
debug1: Reading configuration data /QOpenSys/QIBM/ProdData/SC1/OpenSSH/openssh-3
debug3: Seeding PRNG from /QOpenSys/QIBM/ProdData/SC1/OpenSSH/openssh-3.5p1/libe
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to commpartner.com [10.10.1.1] port 22.
debug1: Connection established.
debug1: identity file /home/ SFTPUSER/.ssh/id_dsa type -1
debug3: Not a RSA1 key file /home/SFTPUSER/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: no key found
debug3: key_read: no space
debug3: key_read: no space

sFTP output information isn’t necessarily easy to read, but it contains all of the information (including the sFTP commands) shown during an sFTP session. I usually specify the -vvv debugging level to gather all the information I can. I may not need it, but it’s there if I do. It’s especially helpful when first establishing an sFTP connection.

 

Michael Ryan is a technical editor with IBM Systems Magazine. Michael can be reached at michael@ryantechnology.com.



Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

Going Mobile With DB2 Web Query

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

Directing i

How to enable IBM i for management by IBM Systems Director

IBM i > ADMINISTRATOR > SYSTEMS MANAGEMENT

Putting the "V" in Virtualization

IBM eServer line delivers on the promise of virtualization

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters