Package: pubpaste
pubpaste - publish files and clipboard online easilyThis tool makes it easy to publish files, clipboards, screenshots,
and photo galleries online with a single command. It's somewhat messy
but it does its job well.pubpasteis not for novice users: it assumes you have access to an
SSH server and know how to configure a YAML file. It has been written
by and for its author in a fit of egoistical mania (unfortunately
typical for hackers), apologies normal humans out there reading this.TutorialHow-toConfigurationScreenshotsImage galleriesClipboard supportSecret tokensHistoryExpiryShortcutsInstallationCreditsChanges frompublishContributingTutorialTo publish a file:pubpaste foo.jpgThe file is then uploaded, withrsync, in a directory with a
secret name, which will generate a URL like this:https://example.com/2020-04-20-oMz_C_6Njja_3VbW-f17LFiTAgNsnp22fqTwjQOgmF4/foo.jpgThe published URL is available in the clipboard,control-vin another window to share the results. That URL should be safe from
guessing as long as the server is properly configured.If a filename is not provided, text is read from standard input and
uploaded as astdin.txtfile. That name can be changed with the--stdin-nameflag.You can also upload the currentselectionwith:pubpaste --xselectionYouMUSTconfigurepubpastebefore the above works, however. SeeConfigurationbelow.pubpastesupports many more ways of sharing content, see the
detailed how-to below for more information on screenshots, photo
galleries and more...How-toConfigurationpubpasterequires manual configuration before it
works. Specifically, theoutputandurl_prefixshould be set in
the configuration. For example, this will tellpubpasteto rsync
files toshell.example.com, in the~/public_htmldirectory, and
that this directory is exposed ashttps://example.com/~user:output: "shell.example.com:public_html/"
url_prefix: "https://example.com/~user"This configuration must be stored in~/.config/pubpaste.yml. Other
configuration file paths can be provided with the--configcommand-line argument orpubpaste.ymlin the$XDG_CONFIG_HOMEdirectory (which defaults to~/.config).Any parameter (likefollow_symlinks) can be specified in the
configuration file as well. The rule is that dashes (-) MUST be
converted to underscores (_).Note that theoutputdirectory should not have directory listings
enabled, see theSecret tokenssection for more
information.Some settings are not visible in the usage because they are better
suited to be used in the configuration file. Here's a sample
configuration file with all the settings not mentioned in the usage:output: "shell.example.com:public_html/"
url_prefix: "https://example.com/~user"
base_dir: /home/user/public_html/
save_screenshots: ~/snaps/They can still be used on the command-line, of course.ScreenshotsTo publish a screenshot withmaim, use:pubpaste --screenshotThis will:start a terminal to show the maim timerstart maim to select a window, it will wait 3 seconds before
taking the screenshotpreview the screenshot using your favorite image view (withxdg-open(1))ask for confirmation before uploading (withxmessage(1))then upload the fileScreenshots therefore require a bit more configuration than other
mechanisms. First install the dependencies:apt install maimInstallsomeimage viewer, for example this is the default image
viewer that comes with GNOME:apt install eogxdg-open(1)andxmessage(1)are very likely already installed on
your computer but if they aren't:apt install x11-utils xdg-utilsYou might not like the defaultxdg-open(1)picks when opening an
image. To change that, use:xdg-mime default application mimetype(s)For example, this will pick theEye Of GNOMEimage viewer:xdg-mime default eog.desktop image/pngTo see which application is currently in use, see:xdg-mime query default image/pngBy default, screenshots are not kept locally. But they can be retained
by setting thesave_screenshotsconfiguration to a directory, for
example this will keep all screenshots in$HOME/snaps:save_screenshots: ~/snaps/Image galleriesBuild an image gallery withSigal:pubpaste --sigal *.JPGThis will generate an image gallery in a temporary directory and
upload it to the server as a whole. The gallery configuration is
currently hard-coded, but could eventually be added to the
configuration file.Clipboard supportWhen doing any upload, the remote URL will be copied to the X
clipboard (the "CLIPBOARD" selection) that you paste withcontrol-v, orcontrol-shift-vin a
terminal. That is different from the Xselection, which you paste
with themiddle mouse button.Note thatpubpastereadsfrom the X "PRIMARY" selection (the
highlighted text), when you use:pubpaste --xselectionThe idea behind this asymmetry is that we do not want the URL to
override the current selection. By copying the URL in to the
clipboard instead of the selection, we keep the current selection
active. The clipboard is also more "durable" as it doesn't get change
whenever you select some text.You can use the--xclipboard(-C) argument to upload the
"CLIPBOARD" selection instead:pubpaste --xclipboardDo note that this works with "Copy image" links. For example, say you
have an image in your web browser, you can right-click on it and pick
the "Copy image" link, then callpubpastewith-xand it will
upload the image without having to first download the image as a file.This is also useful to upload screenshots done within Firefox (in the
"..." menu of the URL bar, "Take screenshot").Image support only works if GTK and its Python bindings are installed.Secret tokenspubpastepublishes files under a specified root directory but with a
unique token made of the current date (YYYY-MM-DD) and a random,
presumably hard to guess, string. That token can be overridden with the--token(-T) flag. For example, if you do not worry about
confidentiality and actuallywanta meaningful name, you can upload
a file publicly with:pubpaste --token my-new-bike bike.jpgOtherwise a properly secure token is generated. Note that directory
listingsmustbe disabled for the secrecy to work: if you pointpubpasteat a directory with directory listing enabled, all the
secrets will bepublicand the entire security of the system will
fail.This can be fixed simply by adding an emptyindex.htmlfile into theoutputdirectory (if the web server is configured to serve those) or
by disabling directory listing (Options -Indexesin Apache, for
example).Historypubpastekeeps an history of the things it has uploaded, in~/.publish.history. This allows you to cancel the last upload, for
example:pubpaste --undo... or arbitrary uploads:pubpaste -T TOKEN --undoSimilarly, you can republish over the previous upload with:pubpaste --republish ...History can be displayed with theshow-historycommand. The last
token used is also accessible with thelast-tokencommand.ExpiryBy default, uploads never expire. You can add a "TTL" (Time To Live)
file with the--ttlargument which marks (in days) the time a paste
should be kept.Old entries can be purged by deployingpubpasteon the server side
and running:pubpaste --purge --base-dir=/home/user/public_html... where/home/user/public_htmlis the path provided inoutputon
the clients. That configuration will usually be store in the configuration
file, as such:base_dir: "/home/user/public_html"ShortcutsThe usage has all the details but if you usepubpastefrom the
command-line, you might like to use shortcuts for the commands. For
example, a screenshot ispubpaste -S. See--helpfor details.InstallationThis package is available on PyPI. It can be installed withpip:pip install pubpasteIts requirements are minimal so you shouldn't need avirtual
environment.pubpastecan also be ran directly from the source directory:./pubpaste.pyor symlinked in your$PATH:ln -s $PWD/pubpaste.py /usr/local/bin/pubpasteKnown issues and limitationsHas no unit tests, but has been refactored to make that possible
lately.The photo gallery and screenshot code is messy.Was written over a weekend and might be buggy.Restricted to elite hackers that have SSH or rsync access and their
own web server. Could be improved by supporting things like S3,
"paste bins" or other file sharing systems.In particular, mis-configuration of the web server can easily be
catastrophic: ifIndexesis enabled in the web serverandthe
parent directory doesn't have anindex.htmlto protect from leaks,
the secret tokens will be revealed and the secrecy of the system
compromised.Similarly, secret tokens can easily leak if any peer that received it
share it by mistake or maliciously. Access revocation is impossible
without renaming the token, which must be done by hand.CreditsThis project was inspired by thepublishprogram originally written
by Florian Reitmeir and Peter Palfrader. It was re-written in Python
to make it easier to document, extend, and maintain.It was renamed because we did not want to take over thepublishnamespace out of respect for the existing one. It's also a little too
generic for a project name.pubpasteseemed like a nice alternative and didn't seem in use
according to search engines (checked DuckDuckGo, Google, GitHub, and
GitLab).pubrefers to the inspiration for this project, thepublishshell
script that influence the command-line design and implementation.pasterefers to the clipboard support. thereforepubpastemeanspublish this paste, but it can of course do more than just publish
the clipboard.pubis also a reference to the real-world place that I dearly miss
since the start of the global pandemic that has everyone isolated and
bars closed.pub pastetherefore obliquely refers to the stickiness
and smell of old pubs and bars, that strange smell of old yeast and
alcohol mixed with bleach or strong cleaning product that lingers
until you walk into a sound check the next day.This is a message of hope: this will not go on forever and the
messiness of humanity will return humbled yet improved.Changes frompublishWhilepubpastegenerally tries to be backwards-compatible withpublishin terms of command-line interface, it has the following
changes:usage is clearer. different actions are "commands" that are
clearly outlined in the usage and correctly "conflict" with each
otherlong options:publishonly has one-letter options,pubpastesupports longer form options as well--undodefaults to the last token, ie.--republishis implicit--undoremoves the token from history, allowing the user to
"pop" backwards in the history, canceling multiple entries--purgeis builtin instead of being a separate scriptthe-L | --follow-symlinksoption is newphoto gallery: the--sigaloption is newThe following are general behavior changes:builtin graphical notifications: whilepublishcan be modified
(through hooks) to notify the user on upload,pubpastedoes
this outside the box.We usexclip -selection clipboardby default instead ofxclip, because the latter conflicts with the-xoption. If
available, we use GTK to handle clipboard events, which gives us
image support.configuration file path and format:publish's configuration is a shell
script in~/.publish.cfg,pubpaste's configuration is a YAML
file in~/.config/pubpaste.yml. this breaks backwards
compatibility.extensibility:pubpasteis less extensible thanpublish. the
latter has "hooks", shell functions that run before and after
various points in the program, and that the configuration can
totally override. this is very powerful, but also not well
documented and possibly dangerous. we took a more traditional
approach inpubpaste: modifications should be done in the source
code and proposed as patchesThe following functionality is missing:-q: encodes the URL in a QR code and uploadsthatmaximum history sizeThose options were discarded and will not be implemented:-8: web server should be properly configured-robscure rsync function i never useis_textdetection: we will just assume stdin is textPrior artSimilar projects include, apart from the above publish, ordered
alphabetically:0bin.net: client-side encrypted, Javascript0x0.st: AKA "the null pointer", minimalistic paste binStikked: PHP, "advanced and beautiful"dpaste: novel idea: paste over the DHThardbin: IPFS-basedix.io: possibly the OG minimal paste bin (2009)microbin: expiry, raw files, rust, qrcodes, expirypastebinit: supports publishing text to multiple paste sites,
Pythonpasthis: PHP-based, also command-line toolplowshare: (collection of) shell scripts to do somewhat the
same, delegates site-specific features to unbundled scripts,removed from Debian because security liabilityprivatebin: minimal, client-side encrypted, PHPtermbin/fiche: minimalist; not even curl, just nc, Ctransfer.sh: minimalist, Golangup1: client-side encrypted, JavascriptI am not including here the list of actual sites deploying some of
those tools or other proprietary ones.This list is likely incomplete. Note, that said, that none of the
above implementation have the feature set of pubpaste (not even
publish). pubpaste and publish both lack the ability to do client-side
(i.e. browser-based) encryption (no, OpenPGP, Age, or OpenSSL do not
count).ContributingSee thecontribution guidefor more information. In
short: this is a free software project and you are welcome to join us
in improving it, both by fixing things, reporting issues or
documentation.This project adheres to theCovenant code of conduct.