Automatically run commands after SSH login to Windows server

Is there a way to run commands automatically when user logs in with SSH to Windows Server?

I tried to implement this using the AutoRun in Command Processor registry, which runs commands when any cmd.exe is started, but due to the complexity of the script in question, this just ends up in endless recursion every time no matter how I try to fix the situation.

I also don't want to run these commands when it's not SSH, but if it's a working option to check it's the first CMD, not anything spawned inside it, I can check the existence of SSH_TTY variable to exclude non-ssh logins.

1 Answer

You should be able to configure the default shell to be your script and have it execute the real shell at the end.

echo Welcome to my server
%COMSPEC%

See Configure default shell initialized by OpenSSH on Windows 7.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like