Docs

The signing key and copies

Keep the site's private signing key in wp-config.php rather than the database, give each environment its own and tidy up after copying the live database.

4 min read WordPress 6.6+ Updated 2 Dec 2026

Where the signing key lives

When an admin connects a site, it makes an Ed25519 key pair, its signing key, and sends only the public half to w-pencil.cloud. The private half signs every request after that. It is kept in the database, in the w_pencil_connection option, unless wp-config.php gives one.

This isn't the one-time site key (WPK-…) an admin can paste to connect: Install and connect covers that.

Keep it out of the database

  1. Make a signing key, 32 random bytes in base64:

    Terminal
    $ php -r 'echo base64_encode(random_bytes(32)), "\n";'
  2. Put it where the server keeps its secrets: in wp-config.php, or as an environment variable of the same name, which a hosting panel or Docker can set.

    PHP
    define( 'W_PENCIL_KEY', 'paste the 44 characters here' );
  3. Then connect the site. W-Pencil › Account shows Key kept in "wp-config.php (W_PENCIL_KEY)", wp w-pencil status adds "(W_PENCIL_KEY)" after the fingerprint, and Site Health says "W-Pencil's key is in wp-config.php".

The signing key is then in no database dump or backup. A copy of the database carries the connection but not the signing key, so it can't sign requests as the live site.

Set it before connecting. w-pencil.cloud only knows the public half of the signing key the site connected with. If you add or change W_PENCIL_KEY later, the site's next request is refused and it forgets the connection. Connect it again, with Connect W-Pencil or wp w-pencil connect, and the old signing key stops working.

A value that isn't 32 bytes in base64 is ignored, and Site Health says "W_PENCIL_KEY is not a key". wp-config constants has the details.

One signing key for each environment

  • Web servers of one site share the same W_PENCIL_KEY. A server without it can't sign.
  • Staging, test and local sites get their own, or none. A site that has the live site's signing key and a copy of its database could sign requests as the live site.

After copying the live database

A copy of the database carries the live site's connection. On another host that isn't a local one, W-Pencil spots it: its host isn't the one the site was connected from. Then it stops counting and tells admins "This site looks like a copy of example.org, so editing here doesn't use its edits." w-pencil.cloud checks too, from the X-PP-Host header each request carries, and gives a copy no allowance. Local development says what happens on local copies.

Make the tidy-up part of the script that copies the database, straight after the import and before any wp search-replace:

Terminal
$ wp w-pencil disconnect --local --yes
  • Always add --local on a copy. It forgets the connection on the copy only, without telling w-pencil.cloud. A plain disconnect from a host W-Pencil doesn't take for a copy would stop the signing key the copy shares with the live site.
  • On the copy's W-Pencil › Account, Disconnect only forgets the connection there, as --local does.
  • Want W-Pencil on the copy too? Press Connect separately in the notice, and connect it as a site of its own. Its edits then come out of the account it joins: the trial's 100 during a free trial, or the packs'. An account with no plan has none to give.

After a search and replace. wp search-replace changes the live address stored in the copied connection too, so the copy no longer looks like one on its own. w-pencil.cloud still compares the host the copy answers on with the origin it knows: it gives the copy no allowance, and the copy's saves are free. W-Pencil remembers that answer and shows the copy notice from then on.

Next in Hosting notes

Multisite.

On a network, each site has its own W-Pencil: its own trial, connection, settings and edits. Network activation, sub-domain and sub-directory networks, and uninstalling.