10

I'm trying to send an ssh command non-interactively to an HP automation server's proxy, and while I can ssh in and enter it interactively perfectly fine, I always get the message "exec request failed on channel 0" when attempting to send the command over non-interactively. Is there anything that I could change on the client side to allow me to send the command over? There's not much that I can change on the server side.

enter image description here

Apparently it's possible, but I just can't get it working on my install (see link: https://community.hpe.com/t5/Network-Automation-Practitioners/Is-there-a-way-to-issue-a-command-to-an-NA-proxy-using-SSH-non/m-p/6935003/highlight/false#M2821)

In case it would help, here are the version details for my OS and openssh version:

OpenSSH_7.2p2, OpenSSL 1.0.2j-fips  26 Sep 2016

NAME="openSUSE Leap"
VERSION="42.2"
ID=opensuse
ID_LIKE="suse"
VERSION_ID="42.2"
PRETTY_NAME="openSUSE Leap 42.2"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:leap:42.2"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"

Thank you

3 Answers 3

1

Usually because the client is asking for a tty, and the server is refusing. Try NOT requesting tty with an ssh -T ......

1

The server is allowing you to open an interactive shell but not the exec system call to execute a command without a pseudo-terminal. Use the -t switch as follows to force pseudo-terminal allocation.

ssh [email protected] -p 8022 -t show version

Alternatively, use expect to script an interaction with the remote endpoint. See this answer for an example.

References:

-1

Do you have anything in your shell rcfile (.bashrc, .zshrc, etc) or .login, .profile, etc that is checking to make sure the shell is interactive before it runs? If not, that's where your problem lies.

My advice is to temporarily rename things like .profile, .bashrc, .login, and .bash_profile to be .profile.off (and so on) and see if the problem still exists.

If it doesn't, you need some code in the offending rcfile that will check to make sure the shell is interactive before it runs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .