You can “mount” a remote file system as a local directory over sshfs. (ssh file system).
Getting this working was a challenge. I do not know if it is an FTP problem, or a z/OS problem
The command, from Linux, is
sshfs colin@10.1.1.2: ~/mountpoint
where mountpoint is a local directory, and my z/OS system is on 10.1.1.2
This flows into the SSH daemon (SSHD) on z/OS which handles the handshake and encryption.
For the IBM provided SSHD, the /etc/ssh/sshd_config config file has
Subsystem sftp /usr/lib/ssh/sftp-server
Where /usr/lib/ssh/sftp-server is the executable to do the work. The IBM supplied object is a load module. You could replace this with a script or other module.
Once the session has been established you can access the files, as if they were on the local system.
What is running on z/OS?
If you use the ps -ef command it displays
UID PID PPID CMD
OMVSKERN 50397264 67174474 /usr/sbin/sshd -f /etc/ssh/sshd_config -R
COLIN 67174482 50397264 /usr/sbin/sshd -f /etc/ssh/sshd_config -R
COLIN 50397267 67174482 sh -c /usr/lib/ssh/sftp-server
COLIN 83951719 50397267 /usr/lib/ssh/sftp-server
This shows the calling chain – the first (SSHD) is at the top, and the last, /usr/lib/ssh/sftp-server, is doing the work to process the files
The shell used depends on the OMVS(PROGRAM()) defined for the userid.
When did sshfs work?
If I had OMVS(PROGRAM(‘/bin/sh’)) then the sshfs worked ok, I could used the files as expected.
If the program was for bash or for zhs, then the data as seen from Linux was in EBCDIC and so was not usable.
So how do I use zsh or bash?
I got round this problem…
I specified the userid as having OMVS(PROGRAM(‘/bin/sh’)), and changed to use the bash shell in the logon script
If I logon with ssh colin@10.1.1.2 then there are environment variables in /etc/profile and ~/.profile.
SSH_CLIENT="10.1.0.2 44898 22"
SSH_CONNECTION="10.1.0.2 44898 10.1.1.2 22"
SSH_TTY="/dev/ttyp0000"
In my ~/.profile I’ve put
if [[ ! -z "$SSH_CLIENT" ]]
then
set -x
# SSH_CLIENT has a value ... so an SSH terminal
# bash="/usr/lpp/Rocket/rsusr/ported/bin/bash"
bash="/u/zopen/usr/local/bin/bash"
echo "shell $SHELL bash $bash"
if [[ $SHELL != $bash ]]
then
echo "using the bash shell"
export SHELL="$bash"
exec "$bash" # replace the current script with bash
# any code after the exec is not executed
fi
fi
which says. If the $SSH_CLIENT variable is not the empty string, (the session came in over an ssh connection) then invoke $bash, and it replaces the current environment with the /u/zopen/usr/local/bin/bash.
With this I could use both sshfs for remote file access, and ssh for terminal access.
If there are better ways of doing this, please let me know