Suppose I have two hosts: A and B with users a and b. B is Windows machine with Cygwin installed, if this matters.
B is configured to be accessed from A through SSH without password (it contains A's public RCA key), so I can run commands on it from A in the following way:
ssh b@B [command]
But when I try to run a command, that requires to access an environment variable, the command fails:
[15:54:08] - a@A - ~ $ ssh b@B 'echo $ANT_HOME'
returns empty string.
The same command, if connected directly (not through SSH) is executed correctly:
b@B ~ $ echo $ANT_HOME /cygdrive/c/PROGRA~1/apache-ant-1.9.0
The latter is possible because the relevant variables were exported in "bash_profile":
export JAVA_HOME="/cygdrive/c/PROGRA~1/Java/jdk1.7.0_45" export ANT_HOME="/cygdrive/c/PROGRA~1/apache-ant-1.9.0"
but for some reason this is not applied to the SSH case.
Some additional info that may be useful.
Host B has Windows XP + Cygwin. CYGWIN sshd is run under SYSTEM account. JAVA_HOME and ANT_HOME are defined in "system" environment variables part in Windows.
When I run "$ ssh b@B env" command, it does not print ANT_HOME or JAVA_HOME, but if I include them in sshd_config file, it does. But even then simple command ssh b@B 'echo $ANT_HOME' does not work as I would expect.
Please give me a hint what needs to be done to run the command through SSH.