Use Your Pubnix as a Personal Permanent Pastebin Service

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:

  1. Full control of the content and their retention period - I wanted to have permanent retention, which isn’t available in most such services.

  2. The re-use of authentication as your pubnix account (via SSH authorized keys, or any other ways you prefer).

  3. 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.

The Use of SSH Aliases

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

A Note on Privacy

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.

The pastry Program

Hosted at https://tildegit.org/klu/pastry

Usage:

  1. Put it in home directory as pastry and chmod u+x ~/pastry

  2. Make a directory p in public html root

    1. chmod go=x p to prevent directory listing
    2. echo 'hello' > p/index.html && chmod go=r p/index.html as additional safeguard
  3. Configure pastry by creating ~/.pastryrc:

     URL_ROOT="https://klu.sdf.org/p"
     LOCAL_ROOT="$HOME/html/p"

vim: set wrap tw=78: