pcopy

pcopy is a tool to copy/paste across machines. It can be used from the web UI, via a CLI or without a client by using curl. It can also be used as a self-hosted NoPaste or as a temporary file hosting service.

After installing the pcopy server, you can use the pcopy command line tool to copy from STDIN (pcp < file.txt) and paste on any connected machine to STDOUT (ppaste > file.txt). If you don't have pcopy installed, you can also use its super simple REST API to copy/paste, e.g. via curl.

The web UI allows you to paste text or upload files (even if they are gigabytes in size), and generates temporary links you can share with others.

Features:

  • 📋 Copy/paste across computers (via STDIN/STDOUT)
  • 🔒 HTTPS secure server (via cert-pinning)
  • 🔑 Clipboards can be password-protected, or they can be open for everyone
  • 📚 Support for multiple clipboards (e.g. personal, work, ...)
  • 🌎 Simple Web UI for uploading text snippets or large files
  • 🔗 Direct temporary links to clipboard content (with TTL/expiration)
  • 💻 No-install curl-compatible clipboard usage (e.g. curl nopaste.net)

demo-simple--1-

Installation

Binaries can be found on the releases page.

Debian/Ubuntu (from a repository):

curl -sSL https://archive.heckel.io/apt/pubkey.txt | sudo apt-key add -
sudo apt install apt-transport-https
sudo sh -c "echo 'deb [arch=amd64] https://archive.heckel.io/apt debian main' > /etc/apt/sources.list.d/archive.heckel.io.list"  
sudo apt update
sudo apt install pcopy

Debian/Ubuntu (manual install):

wget https://github.com/binwiederhier/pcopy/releases/download/v0.5.3/pcopy_0.5.3_amd64.deb
dpkg -i pcopy_0.5.3_amd64.deb

Fedora/RHEL/CentOS:

rpm -ivh https://github.com/binwiederhier/pcopy/releases/download/v0.5.3/pcopy_0.5.3_amd64.rpm

Docker (see detailed instructions):

docker run --rm -it binwiederhier/pcopy

Go (requires Go 1.16rc1):

go get golang.org/dl/go1.16rc1
go1.16rc1 download
go1.16rc1 get -u heckel.io/pcopy

Manual install (any x86_64-based Linux):

wget https://github.com/binwiederhier/pcopy/releases/download/v0.5.3/pcopy_0.5.3_linux_x86_64.tar.gz
sudo tar -C /usr/bin -zxf pcopy_0.5.3_linux_x86_64.tar.gz pcopy

After installation, you may want to check out the Bash/ZSH autocomplete instructions.

Usage

Set up a pcopy server

To setup a new pcopy server, simply run sudo pcopy setup (see server setup demo):

sudo pcopy setup
sudo systemctl enable pcopy
sudo systemctl start pcopy

This will walk you through an interactive setup wizard and place a config file at /etc/pcopy/server.conf (see
sample config). The wizard will set up a pcopy user and a systemd service. Once the service
is started, it listens on port 2586 by default.

If you've enabled the Web UI, you can browse to it an paste text snippets or upload files to it (see live demo).

Join an existing clipboard

To join an existing clipboard, you may use pcopy join:

pcopy join private.example.com
pcopy join work.mycorp.com work
pcopy list

You can join multiple clipboards and give each of them an optional alias (see work clipboard above). Each
clipboard has its own config file, either in ~/.config/pcopy or in /etc/pcopy (for root). You can list connected
clipboards with pcopy list.

Start copying & pasting

Now you can start copying and pasting by using pcp (short for: pcopy copy) and ppaste (short for: pcopy paste).
Any connected client, regardless of what computer it's on, can copy/paste like this (see copy/pasting videos):

pcp < foo.txt            # Copies foo.txt to the default clipboard
pcp bar < bar.txt        # Copies bar.txt to the default clipboard as 'bar'
echo hi | pcp work:      # Copies 'hi' to the 'work' clipboard
echo ho | pcp work:bla   # Copies 'ho' to the 'work' clipboard as 'bla'
pcp : img1/ img2/        # Creates ZIP from two folders, copies it to the clipboard

ppaste                   # Reads from the default clipboard and prints its contents
ppaste bar > bar.txt     # Reads 'bar' from the default clipboard to file 'bar.txt'
ppaste work:             # Reads from the 'work' clipboard and prints its contents
ppaste work:ho > ho.txt  # Reads 'ho' from the 'work' clipboard to file 'ho.txt'
ppaste : images/         # Extracts ZIP from default clipboard to folder images/

Advanced features

The server can be configured via the well-documented config file /etc/pcopy/server.conf (see sample config).
Here are a few highlights:

Password-protected clipboard

When you set up a new clipboard via pcopy setup, you can enter a password. That derives a key, which is stored in the
config file (see Key section).
To add a password after initial setup, use the pcopy keygen command.

When joining a clipboard with pcopy join, you'll be asked for a password. When using curl, you can provide the
password via -u :<password> (see curl usage).

Support for multiple clipboards

You can provide an (optional) alias to a clipboard when you pcopy join it (see join).
You may then later reference that alias in pcp <alias>:.. and ppaste <alias>:.. (see copy/paste).

To list all your connected clipboards, simple type:

$ pcopy list
Clipboard Server address   Config file
--------- --------------- ----------------------------
work      10.0.160.67     ~/.config/pcopy/work.conf
default   nopaste.net:443 ~/.config/pcopy/default.conf

Web UI for uploading text snippets or large files

pcopy comes with a Web UI. You can check out the demo.
(Note: I am not a web guy. I could use some help here!)

demo-webui--1-

curl-compatible usage

If you don't want to install pcopy on a server, you can use simple HTTP GET/PUT/POSTs, e.g. via curl. There's an entire
curl help page available too if you just type curl <hostname>. You may use -u :<password> to provide the clipboard
password (if any). Here's an example for the demo clipboard:

# Show curl help page
curl nopaste.net

# Copy/upload to clipboard (POST/PUT both work)
curl -d Howdy nopaste.net/hi-there
curl -T germany.jpg https://nopaste.net/germany

# Paste/download from clipboard
curl https://nopaste.net/hi-there

Streaming contents (without storing them on server)

If you have particularly large files to send across, and you know you only want to send them to exactly one server,
you can use pcp --stream. It creates a FIFO device (mkfifo) on the server side, and will wait until a reading
client (ppaste or curl ..) is connected before sending.

# On machine 1
yes | pcp --stream    # Will block until 'machine 2' is connected

# On machine 2
ppaste | pv > /dev/null

Direct temporary links to clipboard content (with TTL/expiration)

You can generate temporary links to clipboard entries with pcopy link. You can send this link to someone and they
can download the clipboard content without downloading the client or using any command line tools:

$ pcopy link hi-there
# Direct link (valid for 2d, expires 2021-01-29 22:35:09 -0500 EST)
https://nopaste.net/hi-there?a=SE1BQyAxNjA5MTg0MjY1IDM2MDA...

# Paste via pcopy (you may need a prefix)
ppaste hi-there 

# Paste via curl
curl -sSL 'https://nopaste.net/hi-there?a=SE1BQyAxNjA5MTg0MjY1IDM2MDA...'

Limiting clipboard usage

You can limit the clipboard usage in various ways in the config file (see config file),
to avoid abuse:

  • ClipboardSizeLimit: Limits the total size of the entire clipboard (size of all files)
  • ClipboardCountLimit: Limits the number of clipboard files
  • FileSizeLimit: Limits the per-file size
  • FileExpireAfter: Limits the age of a file (after which they will be deleted)

The demo clipboard uses these settings very restrictively to avoid abuse.

Docker usage

To use the pcopy image, simply pull it and set up a few
shell aliases to simplify local usage:

docker pull binwiederhier/pcopy
alias pcopy="docker run --rm -v ~/.cache/pcopy:/var/cache/pcopy -v ~/.config/pcopy:/etc/pcopy -p 2586:2586/tcp -it binwiederhier/pcopy"
alias pcp="pcopy copy"
alias ppaste="pcopy paste"

This maps the following folders and ports (you may choose different host folders):

  • Config folder: /etc/pcopy (image) to ~/.config/pcopy (host)
  • Clipboard folder (only for server usage): /var/cache/pcopy (image) to ~/.cache/pcopy (host)
  • Service port (only for server usage): 2586 (both image and host)

You can then use pcopy just like it was installed on your host system. To use it as a client, run
pcopy join (see join instructions). To set up a server, run

pcopy setup
pcopy serve

Bash/ZSH autocompletion

Tab completion is available for Bash and ZSH. For Bash, when installed via rpm/deb, autocomplete is immediately
available. ZSH autocomplete installation is manual.

Bash (only if not installed via rpm/deb):

sudo wget -O /etc/bash_completion.d/pcopy https://raw.githubusercontent.com/binwiederhier/pcopy/master/scripts/autocomplete_bash
sudo ln -s /etc/bash_completion.d/pcopy /etc/bash_completion.d/pcp
sudo ln -s /etc/bash_completion.d/pcopy /etc/bash_completion.d/ppaste

ZSH:

mkdir -p ~/.config/pcopy
wget -O ~/.config/pcopy/autocomplete_zsh https://raw.githubusercontent.com/binwiederhier/pcopy/master/scripts/autocomplete_zsh
for p in pcopy pcp ppaste; do echo "PROG=$p source ~/.config/pcopy/autocomplete_zsh" >> ~/.zshrc; done

Demo

I run a small nopaste service on nopaste.net that you can play with. It has quite a few
limits in place, but you'll be able to get a feel for it:

  • To join via the command line: pcopy join nopaste.net:443 (see join instructions)
  • Or use the web UI (this is work in progress, I'm not a web designer, please help!)
  • Or simply type curl nopaste.net (see curl usage)

Limits:
Since nopaste.net is publicly available, I put quite strict limits in place. It is limited to
2 GB total, 500 KB per file, 10,000 files. Files expire after 2 days. Also, overwriting files is disabled (which, if
you use it as a personal clipboard, is quite nonesensical, but it makes sense for a nopaste).

I also made a couple more videos to show what else pcopy can do.

Videos

demo-simple

demo-setup

demo-zip

demo-link

demo-webui

demo-curl

Command-line help

Each command has a detailed help page. Simply type pcopy -help, pcp -help, etc. Here's the main help page:

$ pcopy --help
NAME:
   pcopy - copy/paste across machines

USAGE:
   pcopy COMMAND [OPTION..] [ARG..]

COMMANDS:
   Client-side commands:
     copy, c    Read from STDIN/file(s) and copy to remote clipboard
     paste, p   Write remote clipboard contents to STDOUT/file(s)
     join, add  Join a remote clipboard
     leave, rm  Leave a remote clipboard
     list, l    Lists all of the clipboards that have been joined
     link, n    Generate direct download link to clipboard content
   Server-side commands:
     serve   Start pcopy server
     setup   Initial setup wizard for a new pcopy server
     keygen  Generate key for the server config

Try 'pcopy COMMAND --help' for more information.

Building

Building pcopy is dead simple, however it does need Go >=1.16rc1, because it uses embed.
Here's how you build it:

go get golang.org/dl/go1.16rc1
go1.16rc1 download
make build-simple
# Builds to dist/pcopy_linux_amd64/pcopy

To build releases, I use GoReleaser. If you have that installed, you can run make build or
make build-snapshot.

GitHub