Reputation: 343
I have powershell script that open putty.exe in process and i want to send data to this process, how can i do that??? PLEASE HELP!
The process:
$solExe = [diagnostics.process]::start("putty.exe", "-raw -P 2000 127.0.0.1")
Upvotes: 1
Views: 5139
Reputation: 1633
The command line interface for putty is plink.exe. You can use plink to send commands over ssh.
For example: PS C:> c:\progra~2\putty\plink.exe -i C:\credentials\mykeyfile.ppk [email protected] "ls";
Things to remember:
The first time you connect to a server, you'll have to add it to your registry, so this won't work in a non-interactive mode for brand new servers. There isn't a way to disable this.
The key file has to be in ppk format for plink.exe to recognize it. If yours is in pem format, use puttygen.exe to create a ppk file.
The path to the key file cannot contain any spaces, or the command above won't work.
If you want to send multiple commands at once, write them to a file and use the -m switch with plink.exe.
If you need to transfer files, you can use pscp.exe in a similar fashion.
Upvotes: 4