Automatically run commands after SSH login to Windows server

user11281949

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.

Martin Prikryl

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

SSH to server, Sudo su - then run commands in bash

From Dev

Automatically run script/commands after connecting to OpenShift SSH

From Dev

Nested ssh run commands on 2nd server

From Dev

How to run commands on SSH server in C#?

From Dev

Continue/run commands after ssh into VM

From Dev

SSH login shows Only console users are allowed to run the X server

From Dev

SSH is allowing remote connections only after a local login to the server

From Dev

Run scripts automatically in server after ssh connection

From Dev

Expect script: Create method to login to a remote server using ssh and send commands after method has returned

From Dev

Run scripts automatically in server after ssh connection

From Dev

How to run commands automatically on gnome-terminal after log-in?

From Dev

run xmodmap commands after login

From Dev

How to automatically run a command after exiting ssh

From Dev

Automatically run commands over SSH on many servers

From Dev

SSH only after login?

From Dev

automatically login to windows after startup

From Dev

Should "Windows Update" run automatically on a production server?

From Dev

Correct SSH login and commands for Azure bitnami server

From Dev

Run multiple commands automatically after opening command prompt

From Dev

SSH into secondary server and run multiple commands with putty

From Dev

SSH is allowing remote connections only after a local login to the server

From Dev

BASH Script to SSH to another server and run commands as user

From Dev

Unable to run perl script for ssh login to Windows server (using Net::SSH::Perl) from crontab

From Dev

ssh to a server, run couple of manual commands and exit

From Dev

Run tmux on ssh login

From Dev

How to automatically run commands on SSH login?

From Dev

Expect script not sending commands after successful ssh login

From Dev

I want a function to ssh into a server and then run a list of commands

From Dev

Process terminates after SSH logout on windows server

Related Related

  1. 1

    SSH to server, Sudo su - then run commands in bash

  2. 2

    Automatically run script/commands after connecting to OpenShift SSH

  3. 3

    Nested ssh run commands on 2nd server

  4. 4

    How to run commands on SSH server in C#?

  5. 5

    Continue/run commands after ssh into VM

  6. 6

    SSH login shows Only console users are allowed to run the X server

  7. 7

    SSH is allowing remote connections only after a local login to the server

  8. 8

    Run scripts automatically in server after ssh connection

  9. 9

    Expect script: Create method to login to a remote server using ssh and send commands after method has returned

  10. 10

    Run scripts automatically in server after ssh connection

  11. 11

    How to run commands automatically on gnome-terminal after log-in?

  12. 12

    run xmodmap commands after login

  13. 13

    How to automatically run a command after exiting ssh

  14. 14

    Automatically run commands over SSH on many servers

  15. 15

    SSH only after login?

  16. 16

    automatically login to windows after startup

  17. 17

    Should "Windows Update" run automatically on a production server?

  18. 18

    Correct SSH login and commands for Azure bitnami server

  19. 19

    Run multiple commands automatically after opening command prompt

  20. 20

    SSH into secondary server and run multiple commands with putty

  21. 21

    SSH is allowing remote connections only after a local login to the server

  22. 22

    BASH Script to SSH to another server and run commands as user

  23. 23

    Unable to run perl script for ssh login to Windows server (using Net::SSH::Perl) from crontab

  24. 24

    ssh to a server, run couple of manual commands and exit

  25. 25

    Run tmux on ssh login

  26. 26

    How to automatically run commands on SSH login?

  27. 27

    Expect script not sending commands after successful ssh login

  28. 28

    I want a function to ssh into a server and then run a list of commands

  29. 29

    Process terminates after SSH logout on windows server

HotTag

Archive