I have found the solution
first enable on sshd_config user environement
PermitUserEnvironment yes
Then edit $HOME/.ssh/environement
and put PATH and whatever you want
The $HOME/.ssh/environment file can't contain other than variables and comments
for example
good environment file content
HOME=/home/user
PATH=$PATH:/opt/freeware/sbin:/bin:/opt/freeware/bin:/usr/bin:/sbin:/usr/sbin
bad environment file content
source $HOME/.profile
export PATH=$PATH:/usr/bin
The permission must also correct otherwise don't work
correct perms are 0700 for .ssh and 0400 for .ssh/environment
ls -lhd .ssh/
drwx------ 2 username username 4,0K nov 4 16:29 .ssh//
ls -lhd .ssh/environment
-r-------- 1 username username 73 nov 4 16:29 .ssh/environment
The proof that works.
On Linux the command sed_64 doesn't exist, it exist on Ibmaix remote machine on /opt/freeware/bin dir.
ssh linuxmachine sed_64
bash: sed_64: command not found
ssh remoteaix sed_64
Usage: sed_64 [OPTION]... {script-only-if-no-other-script} [input-file]...
-n, --quiet, --silent
suppress automatic printing of pattern space
-e script, --expression=script
.....
WARNING: the .ssh/environment is read before .bashrc and .bash_profile using ssh so if you don't put the correct PATH you will not find some commands, even if correct path is set on .bash_profile, .bashrc
WARNING: This configuration is safe only on home-private environment, don't use on production/serious places. Because the option PermitUserEnvironment allow any user to bypass their login shell and any ForcedCommand.
sshd
's man page, and the sectionLogin Process
. – ott-- May 17 '15 at 18:28