5

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
  • 767
  • 1
  • 11
  • 18
  • 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 Aug 02 '11 at 01:28

1 Answers1

5

Stream from it instead.

ssh me@server cat ~/dir/named_pipe > file.out
Ignacio Vazquez-Abrams
  • 111,361
  • 10
  • 201
  • 247
  • 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 Aug 06 '11 at 02:26
  • Try streaming from the named pipe locally to see if `mcrypt` invokes a bus error even then. – Ignacio Vazquez-Abrams Aug 06 '11 at 02:57
  • 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 Aug 06 '11 at 13:16
  • Unfortunately command-line encryption is not my forte; I usually leave that to GnuPG or OpenSSL. – Ignacio Vazquez-Abrams Aug 06 '11 at 17:38
  • Turns out, I don't need this anymore. However, your answer would have worked if mcrypt would work. :) – Matt Aug 06 '11 at 23:20
  • 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 Jun 03 '17 at 09:14
  • ~ is resolving to my local home directory instead of the remote one. – Peter Chaula Dec 01 '17 at 09:12