The Authinfo library provides authinfo-copy-password which allows you to copy a password from your ~/.authinfo.gpg file, for 10s. You provide the hostname, with completion, and the username, with completion, if necessary, and the code will copy the password into the kill-ring and the system clipboard. After 10s of idletime, it will be purged.

This uses the auth-source library which does the parsing and searching of your ~/.authinfo.gpg file. Note that the variable auth-source-cache-expiry says how long it caches its data, defaulting to 2h. As far as I’m concerned, however, the important part is that the clipboard is cleared after a while in order to prevent mispastes, and that the kill-ring is cleared such that it doesn’t get saved to disk using desktop or some other session management library (see CategoryPersistence).