The files /etc/ssh/cozsftp_config
and /etc/ssh/cozsftp_server_config
can be used to customize the options available for Co:Z SFTP client and server sessions respectively. The permissions for
each of these files should be 0644
.
User and site-wide samples of both of these files are located in the <COZ_INST>/samples
directory.
These samples may be customized and placed at the above locations to make them active.
Each file has the sections notification:
, fixed:
, default:
and
pattern:
which are described below. Additionally, individual users can provide
their own file patterns and defaults (but not fixed options) in copies of these files in
$HOME/.ssh
The individual Co:Z SFTP client and server options are described in: Appendix B, Co:Z SFTP options.
Use the notification:
section to specify site-wide message properties that cannot be overridden
by individual users. When the notify
Co:Z SFTP option is enabled, a message is written to the console on
completion of put and get commands by the Co:Z SFTP server and client. Notifications are also written on completion of remove and rename commands
on the server. For additional information on the notify
option
see Appendix B, Co:Z SFTP options. The table defines the configurable message properties.
The table below defines case sensitive variables that can be used in the message template.
Table C.2. Message template variables
|
Using the example configuration below,
notification: #messageid=COZSS0001I #errormessageid=COZSS0002E #routingcodes= #descriptorcodes= template.1=${user},${remote_ip},${cmd},${comp_code},${reply_code} template.2=${file} template.3=${bs} bytes transferred template.4=${reply_string}
the following message is written to the console on successful completion of a put command to the Co:Z SFTP server:
COZSS0001I COZUSER,192.28.145.64,STOR,0,250 /u/vendor/cozuser/testfile.txt 7956480 bytes transferred Transfer completed successfully.
Use the fixed:
section to specify site-wide options that cannot be overridden
by individual users. Multiple options may be specified on a single line if separated by commas.
In the example below, the smf
option is activated for all users,
and because it it fixed, may not overridden by any user.
fixed: smf
Use the default:
section to specify site-wide options that can be overridden
by individual users. Multiple options may be specified on a single line if separated by commas.
In the example below, the mode
option is set to text
default.
Because this option is set in the default:
section, it can be easily overridden
by individual users.
default: mode=text
Note | |
---|---|
The shell script used to run the Co:Z SFTP subsystem ( |
# cozsftp_config (client) # Set the default codepage for file transfers to EBCDIC Finnish/Swedish default: clientcp=IBM-1138
# cozsftp_server_config (server) # Sets the default codepage for file transfers to EBCDIC Finnish/Swedish default: servercp=IBM-1138
It is often useful to have a set of custom options associated with specific files and/or datasets.
For example, transferring all files with the .pax
extension in binary mode. The
pattern
sections of the configuration files enable file and dataset names matching
a specific POSIX glob pattern to automatically have specific options applied
regardless of the options currently in place.
pattern
sections can be supplied in the site (/etc/ssh
)
versions of the config files and may also be supplied in copies of these files located in the user's
$HOME/.ssh
directory.
Note | |
---|---|
In some cases, it may not be possible for this file to be located in |
Note | |
---|---|
A specific pattern may only be defined once; subsequent definitions read from the config file(s) are ignored. |
When a put
or get
command is issued, the file or dataset name is checked against the patterns in the order that they were
originally read. The options associated with the first matching pattern (if any) are
applied to that specific file transfer. If an option is not defined by the pattern, it is left
unchanged. Once the transfer completes, the overridden options are restored.
Pattern sections have the following syntax:
pattern: [//]<glob_pattern>
pattern-get: [//]<glob_pattern>
pattern-put: [//]<glob_pattern>
If double slashes (//) precede the pattern, it is used to match dataset names, otherwise it is used to match POSIX pathnames. Matching is performed on the name after it has been normalized (e.g. embedded slashes in a dataset name are converted to periods and the characters are converted to uppercase). Please note that DD names will not be not resolved to their catalog name prior to matching.
Patterns follow the UNIX glob pattern syntax, where
the wildcard characters ?
(match exactly one character) and *
(match
zero or more characters) can be used in conjunction with literal characters to provide a match pattern.
For a complete description of the pattern syntax, see the “File name generation” section of
the sh command documentation in the
z/OS Unix System Services Command Reference.
Patterns in either the pattern:
or pattern-get:
sections are used to
match files that are involved in SFTP get operations. Patterns in the pattern:
or pattern-put:
sections are used to match files that are involved in
SFTP put operations. The same pattern may be defined in both a pattern-get:
and pattern-put:
section (with potentially different transfer options). A pattern
specified in a pattern:
section will apply to both operations. Note:
If a pattern is defined in a pattern:
section, it may not also be
defined in a pattern-get:
/ pattern-put:
section, and vice versa.
Determining which argument of the get or put command is used to match a pattern depends on which Co:Z component is being used:
sftp-server patterns (defined in the
cozsftp_server_config
files) are applied as follows:
sftp> get file-or-dsn <dest> # pattern-get: or pattern: section sftp> put <source> file-or-dsn # pattern-put: or pattern: section
cozsftp patterns (defined in the
cozsftp_config
files) are applied as follows:
cozsftp> get <source> file-or-dsn # pattern-get: or pattern: section cozsftp> put file-or-dsn <dest> # pattern-put: or pattern: section
In the following example, a user specifies in $HOME/.ssh/cozsftp_config:
pattern: //*.JCL(*) mode=text
And in a cozsftp session issues the following:
$ cozsftp user@host Co:Z SFTP version: 1.9.3 (5.0p1) 2011-09-01 Copyright (C) Dovetailed Technologies, LLC. 2011. All rights reserved. Connecting to host... user@host's password: ***** cozsftp>lzopts mode=binary cozsftp>get myjcl //HLQ.DEV.JCL(FOO)
Because the target name matches the pattern, the file myjcl
will be transferred
as in text mode even though the current mode setting is binary.
In the following example, consider the Co:Z SFTP server configuration file /etc/ssh/cozsftp_server_config:
pattern: //*.PARTNER.TRANS* space=cyl.3.2,recfm=fb,lrecl=80
And a remote sftp session issues the following:
sftp> put trans0923 //HLQ.PARTNER.TRANS0923
Assuming the dataset HLQ.PARTNER.TRANS0923
doesn't already exist,
a new dataset with that name will be allocated with allocation parameters associated with the
pattern. This example shows how a server can be setup to automatically allocate incoming
datasets based on a predefined name pattern.
For the examples that follow, consider the following configuration files excerpts:
(from $HOME/.ssh/cozsftp_server_config) pattern: *.txt mode=text,clientcp=1252,linerule=crlf
(from /etc/ssh/cozsftp_server_config) pattern: *.zip mode=binary pattern: *.pax mode=binary pattern: *.txt mode=text,linerule=lf
sftp> get myarchive.pax sftp> get mynotes.txt
The file will be transferred in binary mode because it matches the site specified pattern
(via | |
The file myfile.txt will be transferred in text mode with a client code page of 1252 and a
linerule of |