So, HostB has a SSH trust via pre-shared keys from HostA.
HostA> ssh HostB hostname
HostB
HostA> ssh HostB echo `hostname`
HostA
HostA> ssh HostB 'echo `hostname`'
`hostname`
HostA> ssh HostB "echo `hostname`"
HostA
HostA> ssh HostB echo $PS1
user@HostA:$PWD
HostA> ssh HostB 'echo $PS1'
$PS1
I'm at a loss for how to get these types of commands to run remotely. Echo seems to always interpret locally.
sshd_config is setup for PermitRootLogin forced-commands-only.
The authorized_keys is setup for command=$SSH_ORIGINAL_COMMAND ssh-dss <key> user@HostA
Just including that in case it's somehow causing my grief, though it seems more like quoting, trapping, etc.
The idea is this will be used on many systems to run a command, and it'd be nice to be able to prefix returns w/ a hostname for example.
Locally, I could run:
echo "`hostname`: `df -g /tmp|tail -1`"
and get
HostA : /dev/hd3 16.00 4.06 75% 7655 1% /tmp
So that way, if I script to run against a large amount of hosts, I get a hostname prefix for easy output reading.
Though the redirect also brings up another question.
If I do
HostA> ssh HostB cat /etc/passwd|grep user
user:100:<snip>
Is the grep happening remotely, or is the grep happening locally after the data is returned?
Thanks in advance for any insight you can offer.