ADDRESS USS USSCMD SSH causes OPSUSS address space to get hung
search cancel

ADDRESS USS USSCMD SSH causes OPSUSS address space to get hung

book

Article ID: 133831

calendar_today

Updated On:

Products

OPS/MVS Event Management & Automation

Issue/Introduction

Attempting to SSH to a remote Linux box  using ADDRESS USS USSCMD.   The SSH  is successful, and the remote command is executed, however the  OPSUSS OSF address space executing the request remains 'ACTIVE'  and appears to be hung. 




Environment

Release :all supported

Component : OPS/MVS

Cause

The SSH was still waiting on STDIN (when invoked from USSCMD or from within the shell) and therefore was actually still "ACTIVE", and thus the OPSUSS address space never received an end-of-job  but rather timed out waiting.

Resolution

It appears the issue is not specifying "-n" option, which in the OpenBSD is said to be a requirement for SSH running in the background.

Basically the SSH was still waiting on STDIN and therefore actually still "ACTIVE", and the OPSUSS address space never received an end-of-job but rather timed out waiting.


See https://man.openbsd.org/ssh


-n

Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is run in the background.

A common trick is to use this to run X11 programs on a remote machine.

For example, ssh -n shadows.cs.hut.fi emacs & will start an emacs on shadows.cs.hut.fi, and the X11 connection will be automatically forwarded over an encrypted channel.

The ssh program will be put in the background. (This does not work if ssh needs to ask for a password or passphrase; see also the -f option.)

Additional Information

Here is sample code to execute the SSH. 
This specific code is using SSH to execute SENDMAIL on the remote server.

It's really just the "-n"  switch on the sshcmd that makes the difference.


   key = '/path/to/ssh/key'  

   dest = '[email protected]'

   /* Below options get past 'Host key verification failed' if the issue is   */

   /* OPSMVS home directory does not have .ssh dir with KnownHosts            */

      nohost = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'

      cmd = '"/usr/sbin/sendmail -vt < /home/demomoi/mailout.txt"'

      sshcmd = 'ssh 'nohost' -n -i 'key dest cmd  

   /*                     ^^  This switch is needed for ssh background */

   ADDRESS USS "USSCMD COMMAND('"sshcmd"')"