Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I make ssh admin@nas command work if command is in /opt/bin?

On my QNAP NAS File /root/.ssh/rc:

echo "old path is $PATH"
export PATH=/opt/bin:/opt/sbin:$PATH
echo "new path is $PATH"

on my machine:

~$ ssh admin@nas 'echo $PATH'

returns

old path is /usr/bin:/bin:/usr/sbin:/sbin
new path is /opt/bin:/opt/sbin:/usr/bin:/bin:/usr/sbin:/sbin
/usr/bin:/bin:/usr/sbin:/sbin

so the path variable is not preserved. How can I achieve that?

Edit: As I mentioned in my comment below the command I'm trying to use is git or, more specific git-upload-pack and git-receive-pack and probably some others. I want to use them in different locations and occasions and don't want to bother setting up a git config on every machine I use it on or teach my IDE how to communicate with my NAS but rather have my NAS conforming standards. So i figured that all I need is to set the right $PATH

Edit II: what i did try so far was also inserting the export PATH=... as well as adding another echo (to verify they're run) to ~/.bash_profile, to /etc/profile and to ~/.bashrc. Apparently none of them are even executed when I run a non-interactive command like above. If I do ssh admin@nas all of them are executed, but that doesn't help

share|improve this question
    
stick it in ~/.bash_profile –  sharif Apr 19 '13 at 14:35
    
i tried that along with adding another echo (to verify they're run) to ~/.bash_profile, to /etc/profile and to ~/.bashrc. Apparently none of them are even executed when I run a non-interactive command like above. If I do ssh admin@nas all of them are executed, but that doesn't help –  user2298896 Apr 19 '13 at 14:43
    
How about ~/.bashrc? –  Scott Apr 19 '13 at 20:11
    
As described in my previous comment, I tried that –  user2298896 Apr 20 '13 at 12:33
    
log into root using su - –  sharif Apr 22 '13 at 9:37

1 Answer 1

You can enter real address of command instead of command in ssh admin@nas command. Like below:

ssh admin@nas /opt/bin/command-name

share|improve this answer
    
thanks for the reply, this does work but the command I'm trying to use is git or, more specific git-upload-pack and git-receive-pack and probably some others. I want to use them in different locations and occasions and don't want to bother setting up a git config on every machine I use it on or teach my IDE how to communicate with my NAS but rather have my NAS conforming standards. So i figured that all I need is to set the right $PATH –  user2298896 Apr 19 '13 at 11:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.