The problem: I have a backup program (BackupAssist) that can run scripts automatically after a backup. I want to automatically shut down the computer that stores my offsite backups after the backup completes. I have the shutdown part working (with keys instead of passwords so it would work in a script), but I don't know how to send the Linux box a command without using an interactive shell like Cygwin.

I need to be able to send the command with no user interaction at all. A way to simply execute commands from Cygwin in scripts would be ideal, but any solution will do.


plink is an ssh client for Windows.

You can also use the ssh client from OpenSSH from Cygwin.

You will need to have sshd running and available on your Linux machine. If you want to run automated, you probably want to use passwordless ssh keys for this.


If you want to run SSH in Cygwin from a batch file you could try:

@echo off
C:\cygwin\bin\bash ssh user@host 'shutdown -h now'

Fair warning, I don't have a Windows box to test this on.


If you have access to ssh from Cygwin, then ssh user@host <command> will execute <command> in place of the login shell. Alternatively, you can use plink.exe from PuTTY in place of the Cygwin's ssh. (Thanks grawity)

You can also execute multiple commands, e.g.

ssh user@host "first_command ; second_command ; ..."

  • 2
    PuTTY has an equivalent, plink. – grawity Jun 13 '12 at 21:12
  • @grawity Ah! All I had been able to find was PuTTY's -m argument, which seemed kind of clumsy for this. – Darth Android Jun 13 '12 at 21:17

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.