System:
Red Hat Enterprise Linux Server release 7.6 (Maipo), 3.10.0-957.el7.x86_64
GOAL:
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:
#!/bin/bash
DATE=`date '+%Y%m%d'`
SERVERLIST=(
#"server1.com"
"server2.com"
"server3.com"
#"server4.com"
"server5.com"
)
for SERVERNAME in ${SERVERLIST[*]}
do
FILENAME=${SERVERNAME}-config.${DATE}
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
done
adcli
andrealm
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. – GracefulRestart Apr 18 at 18:29echo $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 at 20:46