I'm running an openSSH server on my Windows 10 machine. Is there any way to automatically run a command when any user connects? I want a user that connects over ssh to have no choice but to run a specific command when they join.
Asked
Active
Viewed 359 times
1 Answers
0
I was able to do this using the registry.
I navigated to HKCU\SOFTWARE\Microsoft\ in regedit and created a key called Command Processor. I then created a new Expandable String Value called AutoRun in that key, and set it's value to a .cmd file. Now whenever a user connects to my SSH server it runs the commands in that file. Note that it will now run these commands whenever you run a batch file! I have it set to only run if it is in the home directory in the .cmd file.
I figured this out from this answer: Automatically executing commands when a command-prompt is opened
Mark Deven
- 1,769