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?
You might want to use
plink
(which is shipped with putty) instead of putty for this.Quote from the documentation:
For your example:
Per the putty manual, there is only
-m
which can be used to give it a file containing one or more commands to be executed in sequence.As @GeraldSchneider suggests, PLINK is more suitable, but if you really wanted to use PuTTY this is how you could do it:
First, you need to set a few things up as follows:
hello.sh
.my-saved-session
and click Save then Cancel.my-saved-session
session and click Load./hello.sh -o
.Now you're good to run the command:
putty -ssh user@host -pw password -load my-saved-session
If you have
pterm
(which usually ships withputty
) AND you have a localssh
command line program, you can do the followingwhere
/path/to/your/program
could also bebash -c "some; shell; code"