can't scp a named pipe

4

1

I am trying to encrypt a file on-the-fly, redirecting the output to a named pipe [fifo]. I SSH into my server and run the command:

           $ mcrypt -k key < file > named_pipe

then from my laptop I try to scp it:

           $ scp me@server:~/dir/named_pipe 

and it says

           scp: /users/home/me/dir/named_pipe: not a regular file

Is there any way to do this? Thanks

Matt

Posted 2011-08-02T01:01:12.947

Reputation: 627

I would assume that scp copies file content. A named pipe is not a physical file, hence scp won't try to copy it (try copying /dev/random, for example). Just redirect to a file, or find a way to tunnel the data to your laptop. – new123456 – 2011-08-02T01:28:34.473

Answers

4

Stream from it instead.

ssh me@server cat ~/dir/named_pipe > file.out

Ignacio Vazquez-Abrams

Posted 2011-08-02T01:01:12.947

Reputation: 100 516

I am currently using a server that limits me to scp. Being able to trick scp into transferring the contents of a named pipe, so that I can transfer huge files without buffering them, would be a huge win for me. – Witiko – 2017-06-03T09:14:53.523

~ is resolving to my local home directory instead of the remote one. – peter – 2017-12-01T09:12:44.457

So I finally got around to trying it out: this is what I get: Bus error: 10 (core dumped).. from mcrypt, and the "> file" file is emtpy. – Matt – 2011-08-06T02:26:04.333

Try streaming from the named pipe locally to see if mcrypt invokes a bus error even then. – Ignacio Vazquez-Abrams – 2011-08-06T02:57:31.740

Good call. I try it on a big file [900MB] and it seems to just sit there doing nothing [output being blank] So created a 5MB file from /dev/urandom, and tried encrypting to a regular file [no fifo]. And it invokes the bus error. :\ I try it on my local Ubuntu machine and it works fine. Maybe it's this server or freebsd? :\ Do you of any encryption program to output to stdout? – Matt – 2011-08-06T13:16:33.157

Unfortunately command-line encryption is not my forte; I usually leave that to GnuPG or OpenSSL. – Ignacio Vazquez-Abrams – 2011-08-06T17:38:52.937

Turns out, I don't need this anymore. However, your answer would have worked if mcrypt would work. :) – Matt – 2011-08-06T23:20:47.807