Run Remote Command with PuTTY – How to Execute Commands Remotely

putty

When I do putty -ssh user@host -pw password echo "hi"

I get a network error

But if I do putty -ssh user@host -pw password

An SSH session is successfully opened in a putty terminal. But I just want to run a single command. How do I do this in Putty?

Best Answer

You might want to use plink (which is shipped with putty) instead of putty for this.

Quote from the documentation:

Plink is a command-line connection tool similar to UNIX `ssh'. It is mostly used for automated operations, such as making CVS access a repository on a remote server.

For your example:

plink -ssh user@host -pw password echo "hi"