I am using libssh to connect to a remote machine and execute commands.
The connection works fine, but here's the rub: on the distant machine, the bash that is running while I'm connected is a rbash. When I send ps | grep ungreppable_phrase
to be executed on the other machine, here is the output:
root 25989 25987 0 07:47 ? 00:00:00 rbash -c ps -ef | grep ungreppable_phrase
(I removed the grep command from that list)
So, obviously, rbash
is the remote shell.
Now, rbash man page tells us the startup files are read before any of the rbash restrictions are applied. So, if any of my startup files (/etc/profile, ~/.bash_profile; ~/.bash_user or ~/.profile) contains a definition for PATH
, that definition should be visible when I run my commands. Especially, if there are some executable files in one of the directories of PATH
, I should be able to run it.
Here's a line from my .profile file:
PATH=/home/my_user/bin
Somehow, I managed to run a ls
in there. It does contain executable files.
My ~/.profile is the last file to be sourced, and it doesn't contain any sourcing of another file. Nor any redefinition of PATH
.
But I get a "command not found" error (or something that looks like it very much, the echo $? returns 127).
Can someone tell me why it seems that my .profile file isn't sourced when I remotely log in? Is it due to some code in libssh ? I'm trying to explore it to find if there are some special otpions that are passed to rbash that I can't see with the grep above..
(Since we're in rbash mode, I can't simply require the PATH to be changed)
Many thanks, Pascal