2

I want a ssh session with root account and env variable JAVA_HOME. I have export JAVA_HOME in /etc/bash.bashrc. When running command,

ssh -t root@localhost "source /etc/bash.bashrc; echo javahome=\$JAVA_HOME"

the printout in the shell is javahome=. But when doing following, I can see JAVA_HOME is correctly set.

ssh root@localhost

source /etc/bash.bashrc

echo javahome=$JAVA_HOME

what could be the possible cause? and in generally, how to have a ssh session with JAVA_HOME set. The scripts are run with bash4 on ubuntu12.04-64

PS: I finally put the configuration script into /root/.profile, then everything works... which is kinda workaround but not the solution to the problem...

Richard
  • 14,642
  • 18
  • 56
  • 77

2 Answers2

1

Add the variable definition to /etc/environment.

Grisha Levit
  • 8,194
  • 2
  • 38
  • 53
-1

Maybe this would help: .bashrc at ssh login although I am not sure if it is correct that you are using bash.bashrc file when I would expect .bashrc

Community
  • 1
  • 1
TMC
  • 1