accounts — manage local identities
Login, persist and switch between Nostr identities. Identities are stored in
plaintext at ~/.ndk/accounts.json (file mode 0600) so that subsequent
commands (broadcast, etc.) can reuse the active signer. Override the file
location with the NDK_ACCOUNTS_FILE environment variable.
Security warning: the accounts file contains signing material (private keys or bunker connection secrets) in plaintext. Treat it like an SSH key. Do not commit or share it.
ndk accounts <sub-command> [args]
# login with an existing nsec / hex private key
ndk accounts login nsec nsec1...
ndk accounts login nsec 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
# read-only login (no signing)
ndk accounts login npub npub1...
# connect to a NIP-46 bunker
ndk accounts login bunker "bunker://...?relay=wss://...&secret=..."
# generate a fresh keypair (nsec is printed once + saved to disk)
ndk accounts login generate
ndk accounts list
ndk accounts whoami
ndk accounts switch npub1...
ndk accounts logout
The first account logged in becomes the active one. Use switch to change
the active account; the choice persists across CLI invocations.