Assuming that the user profile to be used is RUSER, you need to set up some folders with the correct permissions.
If the home directory already exists, please run
CHGAUT OBJ('/home/RUSER') USER(*PUBLIC) DTAAUT(*EXCLUDE) OBJAUT(*NONE) SUBTREE(*ALL)
Create the .ssh subdirectory:
MKDIR DIR('/home/RUSER/.ssh') DTAAUT(*INDIR) OBJAUT(*INDIR)
Log in as user RUSER. You can use a security officer account instead, but then you will have to reset the permissions and file ownership back to RUSER.
CALL QP2TERM
ssh-keyscan -t rsa your.customer.com >> ~/.ssh/known_hosts
Log in as user RUSER. You can use a security officer account instead, but then you will have to reset the permissions and file ownership back to RUSER.
CALL QP2TERM
ssh-keygen -b 1024 -f ~/.ssh/id_rsa -t rsa
Send the public key from file "~/.ssh/id_rsa.pub" to your customer.
( The public key is added by the sever admin to "~/.ssh/authorized_keys" file on the SSH server.)
In this case, copy the key file that you received into the .ssh folder.
To copy all xml files from the IN directory on the remote server to the /b2b/incoming IFS folder:
scp -o IdentityFile=~/.ssh/id_rsa yourRemoteUser@your.customer.com:IN/*.xml /b2b/incoming
(The /b2b/incoming folder must exist prior to the copying.)
To run batch file transfer via scp, create a script file like this (called examplescp.sh)
- #! /QopenSys/bin/sh
- scp -o IdentityFile=~/.ssh/id_rsa yourRemoteUser@your.customer.com:IN/*.xml /b2b/incoming
- exit
Execute it in batch via command
SBMJOB CMD(CALL PGM(QP2SHELL) PARM('/folderpath/examplescp.sh')) JOB(SSHJOB) USER(RUSER)
We want to copy all xml files from the IN directory (inside our homedir) on the remote server to the /b2b/incoming folder and delete them from the remote server.
Create a text file called ssh-input.txt that contains:
To run batch file transfer via sftp, create a script file like this (called examplesftp.sh)
Execute it in batch via command
SBMJOB CMD(CALL PGM(QP2SHELL) PARM('/folderpath/examplesftp.sh')) JOB(SSHJOB) USER(RUSER)
CALL QP2TERM
sftp yourRemoteUser@your.customer.com
dir .ssh
mkdir .ssh
cd .ssh
put ~/.ssh/id_rsa.pub authorized_keys