First, a short demo:
$ cowsay hello | ssh sdf ./pastry
https://klu.sdf.org/p/bGDtr
Now go to https://klu.sdf.org/p/bGDtr to check the result.
There’re several things I like about it:
Full control of the content and their retention period - I wanted to have permanent retention, which isn’t available in most such services.
The re-use of authentication as your pubnix account (via SSH authorized keys, or any other ways you prefer).
The relatively short URL.
How does that work? ssh sdf ./pastry connects to the
server sdf and executes the ./pastry
executable script from the user’s home directory. The script takes input
(text or binary!) from stdin and writes it to a designated directory
with a unique and random file name (bGDtr). This directory
is under the user’s public html root folder as named p.
Note the use of shorthand sdf as the SSH host. This is
done on the client side via configuing ~/.ssh/config:
Host sdf
hostname sdf.org
user klu
the parent directory ~/html/p is configured to be not
traversable (chmod go=x). Meaning other pubnix users and
the internet cannot list the directory, either locally at
~/html/p, or via internet https://klu.sdf.org/p/. Another safeguard is there by
having a ~/html/p/index.html, just in case the chmod is
mis-configured.
pastry ProgramHosted at https://tildegit.org/klu/pastry
Usage:
Put it in home directory as pastry and
chmod u+x ~/pastry
Make a directory p in public html root
chmod go=x p to prevent directory listingecho 'hello' > p/index.html && chmod go=r p/index.html
as additional safeguardConfigure pastry by creating
~/.pastryrc:
URL_ROOT="https://klu.sdf.org/p"
LOCAL_ROOT="$HOME/html/p"vim: set wrap tw=78: