Hi!
I have two solaris 10 machines(say 10.1.1.1,10.1.1.2). i have installed rsync on 10.1.1.2,
10.1.1.1:::
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
-bash-3.00$ ssh 10.1.1.2 "echo $PATH"
Password:
/usr/java/bin:/home/ppoker/thirdparty/ruby/bin:/usr/bin:/usr/ant/bin:.:/usr/local/bin:.:/usr/java/bin:.:/usr/local/apache2/bin:.:/home/ppoker/bin
-bash-3.00$ ssh 10.1.1.2 "which rsync"
Password:
no rsync in /usr/bin
-bash-3.00$
10.1.1.2::::::
-bash-3.00$ which rsync
/usr/local/bin/rsync
-bash-3.00$
when i execute the command from another machine through ssh, why is it unable to find the rsync command?
regards,
Kiran
Scott
2
Hi.
-bash-3.00$ ssh 10.1.1.2 "echo $PATH"
Would show the PATH on 10.1.1.1.
Use single quotes, or escape the $ in $PATH.
-bash-3.00$ ssh 10.1.1.2 'echo $PATH'
or
-bash-3.00$ ssh 10.1.1.2 "echo \$PATH"
to see what the path actually is on 10.1.1.2
hergp
3
Non interactive ssh sessions do not read profiles. You can do one of these:
First, you can change the default path in /etc/default/login, let's say:
PATH=/usr/bin:/usr/local/bin
but this affects all users.
Another way is to write
PATH=/usr/bin:/usr/local/bin
into ~/.ssh/environment. But to make this work, you first have to allow user environments in sshd_config:
PermitUserEnvironment yes
Be advised, that this may have security related side effects depending on your scenario.
@scottn!! you are correct...it is showing in path of 10.1.1.1, i escaped the $ and it is now showing correct path::
10.1.1.1:::
-bash-3.00$ ssh 10.1.1.2 "echo \$PATH"
Password:
/usr/bin
-bash-3.00$
@hergp
i checked /etc/default/login file, but path variable is commented in that file.
//code from /etc/default/login file
# PATH sets the initial shell PATH variable
#
#PATH=/usr/bin:
in this case from where it is taking PATH variable for ssh connection?
Regards,
Kiran
hergp
5
If PATH is commented out in /etc/default/login, then the compiled-in default-default-path is used, which is /usr/bin.