How to redirect Windows cmd output from local machine to remote file via ssh

Viewed 288

How can I redirect Windows cmd output from a local (windows) machine to a remote machine and save the output as file via ssh.

For example something like this: cmd /C "hostname | ssh user@host cat > remotefile.txt" This is writing 'hostname' as text to remotefile.txt instead of the command output.

1 Answers

Check if the same command, without cmd and with stdin descriptor (as seen here), would work

hostname | ssh user@host "cat - > remotefile.txt"
Related