title: Generate ed25519 key-pair compatible with openssh
body: <p>I want to generate an ssh key compatible with openssh using ed25519 in go to replace
  <strong>rsa.GenerateKey</strong> since github does not support it anymore.</p>
  <p>It should be the equivalent of:</p>
  <pre><code>ssh-keygen -t ed25519 -C &quot;your_email@example.com&quot;
  </code></pre>
  <p>But I can't find a way to do it.</p>
  <p>For now, I have this code:</p>
  <pre><code>func GenerateSSHKeys() (*ED25519Keys, error) {
      publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)
      if err != nil {
          return nil, err
      }
  
      publicED25519Key, err := ssh.NewPublicKey(publicKey)
  
      if err != nil {
          return nil, err
      }
  
      pubKeyBytes := ssh.MarshalAuthorizedKey(publicED25519Key)
  
      bytes, err := x509.MarshalPKCS8PrivateKey(privateKey) 
      if err != nil {
          return nil, err
      }
  
      privBlock := pem.Block{
          Type:    &quot;PRIVATE KEY&quot;,
          Headers: nil,
          Bytes:   bytes,
      }
  
      privatePEM := pem.EncodeToMemory(&amp;privBlock)
  
      return &amp;ED25519Keys{
          Public:  pubKeyBytes,
          Private: privatePEM,
      }, nil
  
  }
  </code></pre>
  <p>But it seems that the private key is shorter, and I can't explain some weird behavior that I have using it with git or argocd (sometimes it works, but most of the time no).</p>
  <pre><code>-----BEGIN PRIVATE KEY-----
  MC4CAQAwBQYDK2VwBCIEINV+5Hyey1xTblwsVGfGmDCMdZgKQdhf1ublkGO2Qaf+
  -----END PRIVATE KEY-----
  </code></pre>
  <p>How can I end up with something like that :</p>
  <pre><code>-----BEGIN OPENSSH PRIVATE KEY-----
  b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
  QyNTUxOQAAACAxIu+ndqJXpEJLk5c2qsjPvUybP8OANZlSqLaOau9ZCQAAAKCocC5dqHAu
  [...]
  AAAEChVq8FJPCYbKnNFFuISac83mzF+DDFCDrLd9Xva9fQ2zEi76d2olekQkuTlzaqyM+9
  TJs/w4A1mVKoto5q71kJAAAAFnlvdXJfZW1haWxAZXhhbXBsZS5jb20BAgMEBQYH
  -----END OPENSSH PRIVATE KEY-----
  </code></pre>