Red Hat Enterprise Linux Server release 7.6 (Maipo), 3.10.0-957.el7.x86_64


Collect configurations for data from multiple servers to validate they are the same.

What Works:

ssh $SERVERNAME 'yum list installed | grep -E "krb|java|libkadm|realmd|oddjob|sssd|adcli"' >> $FILENAME

What Doesn't Work:

ssh $SERVERNAME 'adcli info domain.name' >> $FILENAME
ssh $SERVERNAME 'realm list' >> $FILENAME

Error Received:

bash: adcli: command not found

bash: realm: command not found

Full Script:


DATE=`date '+%Y%m%d'`


        ssh $SERVERNAME 'yum list installed | grep -E "krb|java|libkadm|realmd|oddjob|sssd|adcli"' >> $FILENAME
        ssh $SERVERNAME 'adcli info domain.name' >> $FILENAME
        ssh $SERVERNAME 'realm list' >> $FILENAME
        ssh $SERVERNAME 'cat /etc/sssd/sssd.conf' >> $FILENAME
  • 3
    Those errors would indicate that the adcli and realm commands are not in the $PATH of the user you are connecting as. You should probably be using absolute paths for the locations of those programs, or you could add whatever directory they are in to your user's $PATH environment variable. Apr 18 '19 at 18:29
  • Just to clarify, those commands are in the user I connected as. When I SSH and run echo $PATH I have the same directories, but when I only pass a command through SSH, it doesn't work. You are correct that not all directories are loaded when passing the command through ssh.
    – alcazaro
    May 17 '19 at 20:46

GracefulRestart is almost certainly correct.

No verify, compare the output of $PATH between on-server exec and ssh to server exec:

[server2.com]# echo $PATH [jumpbox]# ssh server2.com 'echo $PATH'

If the path to 'adcli' & 'realm' are missing on the ssh $PATH env variable, then the simplest way to fix is to simply use the full path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.