Featured image of post Use Named Pipe to Unlock Encrypted File With Remote Key

Use Named Pipe to Unlock Encrypted File With Remote Key

Tutorial on how to unlock encrypted file with remote key.

It been awhile since a made the post, anyway it is what the title suggess, I’m going to show you how to unlock a encrypted file with remote key over ssh and named pipe (fifo). You’ll need to open two different terminals to do this.

# Create the named pipe
mkfifo /tmp/pipe

# It should be in a blocked state, until information is recevied.
age -d -i /tmp/pipe < in.age > out

In the other terminal run the following.

ssh username@server "cat /path/to/key.txt" > /tmp/pipe

It should unblock age and decrypt the file. It’s quite a good way to restrict private key exposure to ram, it much more secure than copying the private key to /tmp on MacOS it just like any other folder, while on Linux it tmpfs in lament terms, anything in /tmp does not go to ram on MacOS but does on Linux. So yes I’d say that name pipe are quite secure as you’re also avoiding clipboard, it’s very easy to accidently paste the private key to non-volatile storage, it happened to me but luckily the storage was encrypted. But with named pipe I don’t get into accidents, everything just stay in volatile ram.

I do not recommend using clipboard for private keys for the reason I mentioned above.

I wonder what other experiment we could do with named pipes? 😁

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy