1

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.

Mark Deven
  • 1,488
  • 9
  • 40
  • 71
  • Possible duplicate of [Automatically executing commands when a command-prompt is opened](https://superuser.com/questions/302194/automatically-executing-commands-when-a-command-prompt-is-opened) – Giacomo1968 Feb 10 '19 at 16:34
  • That’s where I found the answer lol. I was hoping for something just for SSH, not any CMD prompt. – Mark Deven Feb 10 '19 at 16:47

1 Answers1

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,488
  • 9
  • 40
  • 71