-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2029
koalaman edited this page Nov 7, 2014
·
4 revisions
ssh host "echo $HOSTNAME"
ssh host "echo \$HOSTNAME"
or
ssh host 'echo $HOSTNAME'
Bash expands all arguments that are not escaped/singlequoted. This means that the problematic code is identical to
ssh host "echo clienthostname"
and will print out the client's hostname, not the server's hostname.
By escaping the $
in $HOSTNAME
, it will be transmitted literally and evaluated on the server instead.
If you do want your string expanded on the client side, you can safely ignore this message.