Problems setting PATH for ssh remote commands


#1

Hi,

I would like to execute a program via ssh without login
I have the program in the home folder like this: /my/myprogram

Then I try to execute it
[font=Courier]ssh (name)@(host) -p 2222 “myprogram”[/font]

and always says “command not found”

even I have tried to put the PATH in .bashrc, .bash_profile like this:
[font=Courier]PATH=$PATH:$HOME/my
export PATH[/font]

Always that I tried this is the same output:
[font=Courier]ssh (name)@(host) -p 2222 "echo $PATH"
Outputs:
/usr/bin:/bin:/usr/sbin:/sbin[/font]

PS. Also tried to define PATH in .ssh\environment but didn’t work

Any solutions?


#2

If I indicate explicitly the path to the program when executing /home/name/my/myprogram , it will prompt:
jailshell permission denied

It does it even I’m login in an interactive bash shell. why I can’t execute programs indicating the path


#3

Try ~/my/program

Without knowing more about your full command, that’s all I can suggest. I’m guessing that it’s a .sh type executable (shell script), so in my case, I use something like:
ssh me@example.com ~/bin/do_it.sh


#4

Use Keychain and you use your own programs? normally I wrote a script to execute my programs on remote machines (for path and another info) so I do ssh remote.foo.bar sh program.sh

Maybe you only need ssh foo.bar sh program
(on a second thought)
Regards


#5

Thanks sdayman and vicm3, I didn’t realize about using the full path of the program. So is working :slight_smile: