Can I use a nostr private key to generate an ssh key?

Yes, in a way.

Laan Tungir

23. Juli 2025July 23, 2025 · 5 Min. Lesezeit5 min read

Can I use a nostr private key to generate an ssh key? The goal would then be to be able to ssh with your nostr private key to a server that has your public key.#

Grok4:#

Yes, it's possible in a limited and indirect way, but it's not straightforward and requires some technical setup. Directly using a Nostr private key (which is based on the secp256k1 elliptic curve, commonly used in cryptocurrencies like Bitcoin) as an SSH key isn't natively supported by standard SSH implementations like OpenSSH. SSH typically supports key types like RSA, ECDSA (on NIST curves such as secp256r1), or Ed25519 (on Curve25519), but not secp256k1 out of the box.

However, you can derive an SSH-compatible keypair from your Nostr private key, allowing you to effectively use your Nostr identity for SSH authentication. This involves generating a deterministic SSH key (e.g., Ed25519) from your Nostr private key as a seed. Below, I'll explain the concept, feasibility, and a practical method to achieve this. Keep in mind that this creates a derived key, not a direct 1:1 use of the Nostr keypair—your actual Nostr private key remains separate and secure.

Why This Works (Conceptually)#

Limitations and Risks#

How to Do It: Derive an Ed25519 SSH Key from a Nostr Private Key#

You can use tools like openssl or a simple script to hash your Nostr private key and generate an Ed25519 keypair. Here's a step-by-step guide using Bash and OpenSSH tools (assumes you have openssl, ssh-keygen, and basic command-line access).

Step 1: Prepare Your Nostr Private Key

Assume your Nostr private key is a 64-character hex string (e.g., stored in an environment variable for security). Never hardcode it in scripts!

# Example: Set your Nostr private key (replace with your actual key)
export NOSTR_PRIVKEY="your-64-char-hex-nostr-private-key-here"

Step 2: Derive a Seed and Generate the SSH Keypair

We'll hash the Nostr private key to create a 32-byte seed, then use ssh-keygen to generate an Ed25519 key from it. (Ed25519 is recommended for its security and speed.)

# Hash the Nostr private key to create a deterministic 32-byte seed (using SHA-256)
SEED=$(echo -n "$NOSTR_PRIVKEY" | openssl dgst -sha256 -binary | xxd -p -c 32)

# Generate an Ed25519 private key from the seed (ssh-keygen doesn't directly take seeds, so we use a temporary passphrase trick)
# First, create a temporary file with the seed as a passphrase
echo "$SEED" > temp_seed.txt

# Generate the key using the seed as a passphrase, then remove the passphrase
ssh-keygen -t ed25519 -N "$(cat temp_seed.txt)" -f ~/.ssh/id_nostr_derived

# Remove the passphrase (to make it usable without entering it each time; optional but convenient)
ssh-keygen -p -N "" -f ~/.ssh/id_nostr_derived

# Clean up
rm temp_seed.txt
unset NOSTR_PRIVKEY  # Clear from environment for security

Step 3: Set Up SSH Authentication

Step 4: Automate or Integrate (Optional)

Alternatives and Enhancements#

#encryption#nostr#ssh

Written by

Comments

No comments yet. Start the conversation.