2

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 1

0

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
  • 1
    Ah, of course. I did read that but assumed it must be a real shell... Just a simple .bat with "call xxx.bat" and cmd.exe in it did the trick. Thanks. Commented Apr 21, 2021 at 12:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .