SSH Tectia  
Previous Next Up [Contents] [Index]

    About This Document >>
    Installing SSH Tectia Server for IBM z/OS >>
    Getting Started with SSH Tectia Server for IBM z/OS >>
    Configuring the Server >>
    Configuring the Client >>
    Authentication >>
    File Transfer Using SFTP >>
        Handling MVS Datasets and HFS File System Access>>
        Controlling File Transfer>>
        Staging
        Listing Datasets with SFTP Clients>>
        Secure File Transfer Examples Using the z/OS Client>>
            Interactive File Transfers
            Unattended File Transfers
            File Transfers Using REXX Scripts and a JCL Procedure
        Secure File Transfer Examples Using Windows and Unix Clients>>
    File Transfer Using Transparent FTP Tunneling >>
    Tunneling on the Command Line >>
    Troubleshooting SSH Tectia Server for IBM z/OS >>
    Advanced Information >>
    Man Pages >>
    Log Messages >>

Unattended File Transfers

Unattended file transfers of MVS datasets can be executed in JCL by BPXBATCH, BPXBATSL, or oshell. scp2 uses the same syntax for interactive and unattended file transfers. sftp2 has a batch mode for non-interactive file transfers.

Note: User interaction is not possible when using unattended file transfers.

Users must be set up to use a non-interactive authentication method, like public key without a passphrase, for unattended use.

Because user interaction is not possible, the server host key must be stored on disk on the client before unattended file transfers will succeed. More information and examples on storing remote server keys can be found in Sections Authenticating Remote Server Hosts and Fetching Remote Server Keys.

The sample scripts shown in this section can also be found in the /usr/lpp/ssh2/doc/zOS/SAMPLIB directory.

File Transfers Using the scp2 z/OS Client

Example 1: A Unix file transferred to a z/OS sequential dataset

In this example (SCP2GET from SAMPLIB), manual codeset translation parameters are used for overriding the possible file transfer profiles. Required environment variables are defined by using the STDENV DD card. The scp2 command is run by BPXBATCH. Separate step for printing the stdout and stderr message files is required in order to get correct return code from the file transfer operation.

//SCP2GET EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2GET.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2GET.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR551.PARMLIB(SSHENV),
//             DISP=SHR
//SYSTSIN  DD  *
  BPXBATCH PGM /usr/lpp/ssh2/bin/scp2 +
        -oallowedauthentications=publickey +
        user1@remote_host:textfile.txt +
        /FTADV:F=LINE,C=ISO8859-1,D=IBM-1047/__TEST.TEXTFILE
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2GET.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2GET.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

Example 2: A z/OS sequential dataset transferred to a Unix file

In this example (SCP2PUT from SAMPLIB), a specific translate table is used for codeset translation and the source dataset is defined using a DD card.

//SCP2PUT EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2PUT.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2PUT.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR551.PARMLIB(SSHENV),
//             DISP=SHR
//PROGLI   DD  DSN=&SYSUID..TEST.C.LIST,
//             DISP=SHR
//SYSTSIN  DD  *
  BPXBATSL PGM /usr/lpp/ssh2/bin/scp2 +
        -oallowedauthentications=publickey +
        /FTADV:E=STANDARD,A=___TCPIP.%T.TCPXLBIN,F=LINE///DD:PROGLI +
        user1@remote_host:test_c.list
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=100,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2PUT.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2PUT.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

Example 3: A Unix file transferred to a z/OS sequential dataset

In this example (SCP2GET2 from SAMPLIB), the destination dataset is defined and pre-allocated using a DD card.

//SCP2GET2 EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2GET2.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2GET2.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR551.PARMLIB(SSHENV),
//             DISP=SHR
//TESTFI   DD  DSN=USER1.FILE.PS.TEST1,
//             DISP=(NEW,CATLG),
//             VOL=SER=Z6SYS1,
//             SPACE=(TRK,(2,2)),
//             DCB=(RECFM=VB,LRECL=1024,BLKSIZE=27998)
//SYSTSIN  DD  *
BPXBATSL PGM /usr/lpp/ssh2/bin/scp2 +
        -oallowedauthentications=publickey +
        user1@_remoteserver:textfile.txt +
        //DD:TESTFI
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2GET2.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2GET2.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

Example 4: A Windows file transferred to a partitioned dataset member

In this example (SCP2GET3 from SAMPLIB), the remote file is transferred to mainframe as a PDS member. The FB80 profile defines the needed dataset characteristics and codeset translation.

//SCP2GET3 EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2GET3.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2GET3.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR551.PARMLIB(SSHENV),
//             DISP=SHR
//SYSTSIN  DD  *
BPXBATCH PGM /usr/lpp/ssh2/bin/scp2 +
        -oallowedauthentications=publickey +
        user1@_remoteserver:jcl.txt +
        /FTADV:P=FB80,T=PDS/___USER1.JCLLIB/JCL1
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SCP2GET3.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SCP2GET3.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

File Transfers Using the sftp2 z/OS Client

The sftp2 file transfer application can be run in batch mode for non-interactive file transfers.

Example 1: Batch file transfer with two file transfers

In this example (SFTP2BAT from SAMPLIB), SFTP is run in batch mode.

//SFTP2BAT EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SFTP2BAT.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDERR   DD  PATH='/tmp/&SYSUID.-SFTP2BAT.err',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR551.PARMLIB(SSHENV),
//             DISP=SHR
//SYSTSIN  DD  *
  BPXBATCH PGM /usr/lpp/ssh2/bin/sftp2 +
        -oallowedauthentications=publickey +
        -B //'USER1.TRANSFER.BATCH' +
        user1@10.1.70.193
/*
//STDPR   EXEC PGM=IKJEFT1A,
//             DYNAMNBR=75,
//             TIME=1440,
//             REGION=6M
//SYSPRINT DD  SYSOUT=*
//SYSTSPRT DD  SYSOUT=*
//SYSTERM  DD  DUMMY
//STDOUT   DD  PATH='/tmp/&SYSUID.-SFTP2BAT.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDERR   DD  PATH='/tmp/&SYSUID.-SFTP2BAT.err',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//STDERRPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
  OCOPY INDD(STDERR) OUTDD(STDERRPR) TEXT
/*

File transfer commands in the batch file "USER1.TRANSFER.BATCH" can be, for example, the following:

sput /_FILE2.PS /home/user1/file1.dat
sget files/jcl /FTADV:P=FB80/___USER1.PDS/MEM1

Example 2: Batch file transfer without a separate batch file

In this example (SFTP2 from SAMPLIB), SFTP is run in batch mode and the batch commands are given in the same job using an inline file referenced by a DD name.

The sftp2 batch commands do the following steps:

  1. Connect to account REMUSER on the host remhost.
  2. remhost is an MVS machine running SSH Tectia Server for IBM z/OS.
  3. Change to use SYS1.MACLIB as the "current directory".
  4. Transfer a member into a HFS file.
  5. Transfer the HFS file into a new MVS dataset.
  6. Make sure the transfer is completed by listing the dataset.
  7. End the run.

//SFTP2    EXEC PGM=BPXBATSL,
//             REGION=0M,
//             PARM='PGM /usr/lpp/ssh2/bin/sftp2
//             -B //DD:BATCHIN'
//SYSTSPRT DD  SYSOUT=*
//STDOUT   DD  PATH='/tmp/&SYSUID-sftp2.out',
//             PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//             PATHMODE=(SIRUSR,SIWUSR)
//STDENV   DD  DSN=&SYSUID..SSZ.SRVR551.PARMLIB(SSHENV),
//             DISP=SHR
//BATCHIN  DD  *
open REMUSER@remhost
cd /__SYS1.MACLIB
sget CALL /tmp/call-macro
sput /tmp/call-macro /ftadv:o=fb,r=80/__TEST.CALL
ls /_TEST.CALL
quit
/*
//*
//PRINT   EXEC PGM=IKJEFT1A
//SYSTSPRT DD  SYSOUT=*
//STDOUT   DD  PATH='/tmp/&SYSUID-sftp2.out',
//             PATHOPTS=(ORDONLY),
//             PATHDISP=(DELETE,KEEP)
//STDOUTPR DD  SYSOUT=*,
//             DCB=(LRECL=4000,RECFM=VB)
//SYSTSIN  DD  *
  OCOPY INDD(STDOUT) OUTDD(STDOUTPR) TEXT
/*

Previous Next Up [Contents] [Index]


[ Contact Information | Support | Feedback | SSH Home Page | SSH Products ]

Copyright © 2007 SSH Communications Security Corp.
This software is protected by international copyright laws. All rights reserved.
Copyright Notice