I use this a lot, but it has some pretty ugly drawbacks.. When you can’t use scp(like taking disk images via dd and piping them over gzip to the ssh) you have no rate limiting like scp’s “-l” option – that can get pretty nasty if you’re copying stuff between production servers and need to limit it so importand data still can be transferred.

I just discovered that scp actually *does* support reading from stdin, but it doesn’t seem to be documented anywhere.

“scp -t foo” will listen for the scp protocol on stdin and write the decrypted data to the file or directory “foo”. I discovered this just now while testing a “validate-rsync” script to limit what commands my ssh key could invoke.

When I invoked it in an xterm, on both Fedora and MacOSX, it tried to read from stdin.

Apparently the “-t” option is undocumented; it wasn’t in the scp man page on either system, and “scp –help” doesn’t show it. I found this discussion thread while googling for “scp from stdin” to see if I could find any mention of the +-t” option. No luck so far.

Thank you for an excellent hint. I’ve had much trouble with scp on OpenWRT/Dropbear where a script was hanging due to scp awaiting “unknown host” confirmation every time the router has restarted. While ssh has an “-y” option to accept new hosts, scp does not, so your workaround was a life saver.