In SSH, the PATH variable has been overwritten

When using ssh remote command, e.g.,

ssh root@ip "echo $PATH"

We will have result, /opt/render-ssh/bin. Therefore, most remote ssh commands complains “command not found”.
However, the login shell is fine, which can be confirmed by running,

ssh root@ip "/bin/bash --login -c 'echo $PATH'"

After digging into this issue, I found that the PATH variable has been overwritten in the sshd setup scrips: /opt/render-ssh/bin/sshd-render.sh. The main function in the script overwrites the PATH variable to /opt/render-ssh/bin, which is then being written to the sshd config file /opt/render-ssh/var/sshd_config.d/partials/env_vars with sshd’s SetEnv config.

The purpose of writing environment variables of current session into a sshd config file is to preserve environment variables in the coming ssh sessions.

And resetting the PATH variable in that script seems deliberate as there is no other usage of the PATH variable after that, all commands running in that script is written in full path.
Then, what is the reason of doing so? Any workaround for this issue?

Besides, the reason why login shell has suitable PATH variable is that it reset PATH variable when loading /etc/profile.

Hi there,

Thanks for the feedback here, our engineers have confirmed the issue and have raised a work item to investigate further/resolve.

Alan

Cool, thank you.
I thought you might want to do local PATH="${renderSSHBin}:${PATH}" instead.
Where can I trace this issue? As it is critical that it makes running remote ssh command almost impossible.

Hi there,

These work items aren’t available publicly, but I can see the issue is being worked on, so a fix should be available soon. I will update when I have more information.

Kind regards

Alan

A fix for this has now been deployed. Thanks for your patience.

Alan

Thanks! It works after a re-deployment!