Ssh – Path not loaded for user when connecting with SSH

command-line-interfaceenvironment-variablespathsshwindows-server-2008

I have an Windows 2008 Server Instance running on EC2. I have installed an application and added it to the path and it is now available to my Administrator user from the Command Line.

However, when I SSH in to the server as the Admin User, the command is no longer available. If I $echo %path% I cannot see the path to the application I have added.

So it seems that when the same user connects via SSH, a different path is used. But where is this path? Is there a windows equivillant of bashrc that is being loaded instead of the path?

I'm using FreeSSH for the SSH server.

Best Answer

In Windows, %PATH% is generally loaded when an application or service starts, so you'll need to restart your SSH Server after making the change.

Windows also has two path variables, one global, and one per user, so you have to be careful to modify the right one, to get it working as expected.

To further complicate matters, the method of setting the path environmental variable that I see rise to the top with Google (set) is wrong - "Changes made with SET will remain only for the duration of the current CMD session."

The method I've always used, and yet to have problems with, is the setx command. Follow that with a restart of your SSH server service and you should be good to go.