0

I connect with my Windows cmd to another machine with this command:

putty.exe -ssh bob@172.16.17.50 -i C:\Users\Administrator\Desktop\bobPrivate.ppk -pw mypass

And which option I have to add to run a single command and disconnect after that?

jofri
  • 131
  • 1
  • 16
  • 1
    Possible duplicate of [Automating running command on Linux from Windows using PuTTY](http://stackoverflow.com/questions/6147203/automating-running-command-on-linux-from-windows-using-putty) – CherryDT May 04 '16 at 12:46
  • No it is Windows to Windows – jofri May 04 '16 at 12:46
  • If you have a SSH daemon running on the other machine it doesn't matter. Please check out the answers in the other thread. If your problem lies in connecting via PuTTY in the first place (so you don't even *have* an SSH agent on the other side), then maybe you are looking for [`psexec`](https://technet.microsoft.com/en-us/sysinternals/psexec.aspx) instead. – CherryDT May 04 '16 at 12:47
  • I use now the `-m C:\Path\to\file\with\command` option – jofri May 04 '16 at 12:55
  • You might also want to investigate `plink --help` for running a command on another machine. – lit May 04 '16 at 14:16

1 Answers1

0

To execute a command you have to use the -m option.

putty.exe -ssh bob@172.16.17.50 -i C:\Users\Administrator\Desktop\bobPrivate.ppk -pw mypass -m C:\Path\to\file\with\commands

You have to replace the path with yours

jofri
  • 131
  • 1
  • 16