LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2009, 02:39 PM   #1
nlainus
LQ Newbie
 
Registered: Feb 2009
Location: Minneapolis
Distribution: RHEL 4 & 5
Posts: 12

Rep: Reputation: 0
What is the effective SSH $PATH when executing a command


Hi all, I hope I'm in the right forum.

I have a cluster containing 32 compute nodes and 1 head node. I have a common user account which is being exported via the head node to all compute nodes - so all nodes can access the same files and "SHOULD" have the same environment as each other. I also have passwordless ssh and rsh setup between all nodes.

As you will see if you examine the commands below there is something strange happening when ssh'ing. Essentially your effective permissions change when running a command over SSH. I can't figure out where its getting this alternate path variable from. The .bash_profile is shared between all nodes so they should have the same path when entering as that user (fluent).

Any help on this would be greatly appreciated. I've exhausted all my local resources here at work and everyone is stumped.

_________________________________________________
[fluent@colfax60 ~]$ ssh amd-1 echo $PATH
/usr/ansys_inc/v120/fluent/bin:/opt/hpmpi/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/usr/kerberos/sbin:/usr/kerberos/bin

[fluent@colfax60 ~]$ ssh amd-1 'echo $PATH'
/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
[fluent@colfax60 ~]$

[fluent@colfax60 ~]$ ssh amd-1 which fluent
which: no fluent in (/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin)
[fluent@colfax60 ~]$

[fluent@colfax60 ~]$ ssh amd-1
Last login: Wed Feb 18 13:34:06 2009 from colfax60

[fluent@AMD-1 ~]$ which fluent
/usr/ansys_inc/v120/fluent/bin/fluent
[fluent@AMD-1 ~]$
_________________________________________________
 
Old 02-18-2009, 03:47 PM   #2
bluethumb
Member
 
Registered: Jan 2006
Distribution: RHEL 4, Scientific Linux, Centos, Ubuntu
Posts: 58

Rep: Reputation: 15
Interactive vs. non-interactive

From the bash man page:

Quote:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the --norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.

When bash is started non-interactively, to run a shell script, for example, it looks for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the PATH variable is not used to search for the file name.
So when you ssh a command, it uses a different set of dot files than the ones you get in an interactive shell.
 
Old 02-18-2009, 04:02 PM   #3
nlainus
LQ Newbie
 
Registered: Feb 2009
Location: Minneapolis
Distribution: RHEL 4 & 5
Posts: 12

Original Poster
Rep: Reputation: 0
I fixed this folks. Red Hat runs your profile vars like this - /etc/profile /etc/bashrc ~/.bashrc "OR" ~/.bash_profile
Something broke to where it wasn't running the ~/.bash_profile when ssh'ing under certain circumstances but when I added the desired path the ~/.bashrc for that user it all was peachy.

Thanks and I hope this helps someone else down the road.
 
Old 02-18-2009, 04:05 PM   #4
nlainus
LQ Newbie
 
Registered: Feb 2009
Location: Minneapolis
Distribution: RHEL 4 & 5
Posts: 12

Original Poster
Rep: Reputation: 0
Sorry I didn't see your post in time before my own response to resolve this, but thanks for the info! That is much help.
 
Old 02-18-2009, 04:09 PM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
strange..
Ssh command uses path specified when building sshd
Path should not be set in bashrc.
If they are and exported:
Ssh in and type 'bash'
You might have everything doubled
If they are but not exported:
Create a file containing
echo $PATH
Execute it

Last edited by nx5000; 02-18-2009 at 04:57 PM.
 
Old 02-19-2009, 12:17 PM   #6
nlainus
LQ Newbie
 
Registered: Feb 2009
Location: Minneapolis
Distribution: RHEL 4 & 5
Posts: 12

Original Poster
Rep: Reputation: 0
I always thought that running "ssh host command" would take on the permissions of whatever user you were executing the ssh command from. That's how its always worked for me. Then all of a sudden it wasn't working anymore.
 
Old 02-19-2009, 12:23 PM   #7
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
I read the manpage and it says by default, ssh command will take the PATH used while building sshd. Kinda strange. Probably security reasons.

For the rest, I checked a RH and I confirm that it's the default settings, if you put things in .bashrc, you can get them defined multiple times.
So it's cleaner in profile.
 
Old 02-19-2009, 06:01 PM   #8
nlainus
LQ Newbie
 
Registered: Feb 2009
Location: Minneapolis
Distribution: RHEL 4 & 5
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks for the info.
 
  


Reply

Tags
ssh


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
besides logout and log in, how to make the new PATH effective powah Linux - Newbie 3 02-27-2008 06:24 PM
how to get absolute path of current executing C/C++ prog? Thinking Programming 2 10-10-2005 11:27 AM
.bash_profile (hence .bashrc) not executing with ssh arobinson74 Linux - General 1 10-31-2004 10:55 AM
Executing commands without using the full path.. LinuxBAH *BSD 2 12-02-2003 08:16 PM
Printing the path for a currently executing programme tim_l Linux - Software 2 10-10-2003 07:17 AM


All times are GMT -5. The time now is 10:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration