{
  "id": "howto-tech-how-do-you-generate-an-ssh-key",
  "question": "How do you generate an SSH key?",
  "common_queries": [
    "How do I generate an SSH key?",
    "How to generate an SSH key?",
    "How can I generate an SSH key?",
    "How can you generate an SSH key?",
    "What's the way to generate an SSH key?",
    "What is the process to generate an SSH key?"
  ],
  "short_answer": "To generate an SSH key, run ssh-keygen (typically ssh-keygen -t ed25519 -C \"your_comment\") and save the key pair in your .ssh directory.",
  "long_answer": "ssh-keygen creates a private key and a matching public key. The private key stays on your machine and should never be shared or committed to a repository. The public key (the file ending in .pub) can be added to a server's authorized_keys file or to a service such as GitHub. Ed25519 is a modern default when both sides support it; if you need older compatibility, some systems still use -t rsa -b 4096. An optional passphrase encrypts the private key at rest. After the key is generated, you can start ssh-agent and ssh-add the private key so you do not type the passphrase on every connection.",
  "steps": [
    {
      "text": "On Windows, use PowerShell or a terminal that provides OpenSSH.",
      "title": "Open a terminal"
    },
    {
      "text": "A typical command is ssh-keygen -t ed25519 -C \"your_comment\". Accept the default path (~/.ssh/id_ed25519) or choose another, and optionally set a passphrase.",
      "title": "Run ssh-keygen"
    },
    {
      "text": "Copy the .pub file to the remote account or service. Do not share the private key file.",
      "title": "Use the public key, protect the private key"
    }
  ],
  "grade": null,
  "subject": null,
  "category": "tech",
  "tags": [
    "tech",
    "ssh",
    "security",
    "how-to"
  ],
  "sources": [
    {
      "title": "OpenBSD manual page for ssh-keygen",
      "url": "https://man.openbsd.org/ssh-keygen"
    }
  ],
  "updated": "2026-11-20",
  "last_verified": "2026-11-20",
  "canonical_url": "https://answerkb.com/how-to/tech/how-do-you-generate-an-ssh-key/",
  "related": {
    "easier": [],
    "harder": [],
    "siblings": []
  }
}
