Home / Alt manpages / pbput(1)

  • pbput(1)
  • User command
  • linux

Share Files with pbput Without Losing Track of the Data

You will finish with a repeatable way to send a file, directory, or standard-input stream through pbput, retrieve it with pbget, and choose pbputs when the content must be encrypted before upload. Allow about fifteen minutes. You need a shell, the pastebinit package, network access to the configured paste service, and enough free space for temporary compression and archive files.

The examples below describe the installed Debian package version pastebinit 1.6.2-1. This copy sends to paste.ubuntu.com, as shown by the installed script. That differs from the older manpage wording, which names pastebin.com. Treat the URL printed by your own command as the record of where to retrieve the paste.

1. Check the installed tools

Start with read-only checks. These are ordinary commands and do not need sudo:

$ command -v pbput pbputs pbget
/usr/bin/pbput
/usr/bin/pbputs
/usr/bin/pbget
$ dpkg-query -W -f='${Package} ${Version}\n' pastebinit
pastebinit 1.6.2-1

pbput and pbputs are the same shell program selected by the name used to invoke it. They always compress with lzma and encode with base64 before calling pastebinit. pbget reverses that process. An upload is an external write to a paste service, so do not use real secrets or private customer data while learning the workflow.

Checkpoint

Stop here if one of the commands is missing, or if the installed version and service differ from the examples. Do not install packages just to make a copied example fit this guide.

2. Upload text from standard input

Pipe a short, non-sensitive value to pbput when you want the receiver to get the original stream rather than an extracted file tree:

$ printf '%s\n' 'pbput smoke test' | pbput
https://paste.ubuntu.com/p/EXAMPLE/

The URL is variable. Save it immediately; it is the handle needed by pbget. The command's exit status is the first local check:

$ printf '%s\n' 'pbput smoke test' | pbput > /tmp/pbput-url
$ status=$?
$ printf 'upload status: %s\n' "$status"
upload status: 0
$ sed -n '1p' /tmp/pbput-url
https://paste.ubuntu.com/p/EXAMPLE/

Do not treat a plausible-looking URL as proof that the content is correct. The service can reject a request, return an unexpected page, or expire a paste. Remove the temporary URL file when you have finished checking it, but remember that removing your copy does not remove the remote paste.

3. Upload one file or a directory

Passing a readable path makes pbput create a tar archive first. That preserves the path's file or directory structure and attributes before compression:

$ mkdir -p /tmp/pbput-example
$ printf '%s\n' 'example data' > /tmp/pbput-example/notes.txt
$ pbput /tmp/pbput-example/notes.txt
https://paste.ubuntu.com/p/EXAMPLE/

There is no need for elevated privileges when the source and destination are yours. The command reads the path and creates temporary files under /tmp; it does not modify the source. A directory works in the same position:

$ pbput /tmp/pbput-example
https://paste.ubuntu.com/p/EXAMPLE/

Keep the path argument quoted when it contains spaces or shell metacharacters, for example pbput -- "$HOME/my reports". The installed script does not document an option parser, so do not rely on -- as a general-purpose flag. In particular, use paths that do not begin with an option-like string, or pass an explicit path such as ./-notes.

Common trap: if the first argument is not readable, the installed script falls back to reading standard input. A mistyped filename can therefore appear to hang while it waits for input. Cancel with Ctrl-C, check the path without changing anything, and retry:

$ test -r /tmp/pbput-example/notes.txt && echo readable
readable
$ ls -ld /tmp/pbput-example/notes.txt

4. Retrieve and verify the result

Give the saved URL to pbget. With no destination directory, an archived upload is extracted into a new temporary directory:

$ pbget 'https://paste.ubuntu.com/p/EXAMPLE/'
tmp/pbput-example/notes.txt
INFO: Output is in [/tmp/pbget.ABC123]
$ find /tmp/pbget.ABC123 -type f -print
/tmp/pbget.ABC123/tmp/pbput-example/notes.txt

The exact paste URL, temporary directory name and extracted listing are variable. For a plain standard-input upload, pbget writes the decoded content to standard output instead:

$ pbget 'https://paste.ubuntu.com/p/EXAMPLE/'
pbput smoke test

For a controlled extraction location, create an empty directory and pass it as the second argument:

$ install -d -m 700 /tmp/pbput-restore
$ pbget 'https://paste.ubuntu.com/p/EXAMPLE/' /tmp/pbput-restore
tmp/pbput-example/notes.txt
INFO: Output is in [/tmp/pbput-restore]
$ find /tmp/pbput-restore -type f -print

Inspect the restored files before moving them into a real project. The download is remote input, even when the URL came from a colleague. Do not extract into a directory containing valuable files unless you have checked the archive and are prepared for existing paths to be affected.

5. Encrypt with pbputs when confidentiality matters

pbput compresses and encodes; it does not encrypt. Anyone who can obtain the paste and decode it can read the content. Use pbputs for encrypted content:

$ pbputs /tmp/pbput-example/notes.txt
Enter passphrase:
https://paste.ubuntu.com/p/EXAMPLE/

With one readable path, the installed command creates a tar archive and then uses symmetric GPG encryption. It prompts for the passphrase rather than placing it in the command line. Retrieve it with the same passphrase:

$ pbget 'https://paste.ubuntu.com/p/EXAMPLE/' /tmp/pbput-restore
Enter passphrase:

For standard input, put the GPG user as the first argument to pbputs when using public-key encryption, or leave it out for the passphrase prompt. A target user must already exist in your GPG keyring:

$ printf '%s\n' 'encrypted example' | pbputs
Enter passphrase:
https://paste.ubuntu.com/p/EXAMPLE/

Do not put a passphrase, private key material or sensitive data in shell history. Encryption does not hide the fact that a paste exists, and losing the passphrase or required private key makes recovery impossible. The remote paste remains until the service removes it; local deletion is not a recall mechanism.

6. Recover from failures and clean up

If pbget prints nothing useful, first check the URL and network access. Then retry with a known-good paste and inspect the command's status:

$ pbget 'https://paste.ubuntu.com/p/EXAMPLE/' > /tmp/pbget-output
$ printf 'download status: %s\n' "$?"
download status: 0
$ file /tmp/pbget-output

A zero status does not validate the contents. Compare a checksum when you have an independent expected value, or inspect the extracted files and their permissions. Do not execute a restored file merely because pbget extracted it.

Temporary directories and test files in these examples can be removed after verification:

$ rm -r -- /tmp/pbput-example /tmp/pbput-restore
$ rm -f -- /tmp/pbput-url /tmp/pbget-output

Those removals are irreversible for the local copies. Check the paths before running them, and do not adapt the command by replacing the explicit paths with a broad directory or a wildcard. Cleanup does not erase an already-uploaded paste.

Done means

  • You checked the installed pastebinit version and the command locations.
  • You know whether your input came from standard input or a tar archive.
  • You saved and tested the URL returned by the upload.
  • You used pbputs for content that must be encrypted, and kept the passphrase or key separate from the command line.
  • You restored into a controlled directory and inspected remote content before using it.
  • You understand that deleting local files does not remove the remote paste.