How can I generate a private and public key with OpenSSL using Git Bash?

274 lượt xem
Chuyển tới thư đầu tiên chưa đọc

Gilliard Santos

chưa đọc,
11:51:43 25 thg 2, 202425 thg 2
đến git-for-windows
😀 Hello Git Community, how are you? 😀

- The Git Bash Terminal Installer includes OpenSSL, and my OpenSSL version is 3.1.4 (24 Oct 2023) (Library: OpenSSL 3.1.4 24 Oct 2023).

- How can I generate a public or private key using Git Bash?

Thank you all.

Gilliard Santos

chưa đọc,
11:51:43 25 thg 2, 202425 thg 2
đến git-for-windows

Johannes Schindelin

chưa đọc,
02:41:41 26 thg 2, 202426 thg 2
đến Gilliard Santos, git-for-windows
Hi,

This does not seem to be a Git question at all. And the web has a lot of
answers for this question, e.g
https://stackoverflow.com/a/44474607/1860823:

You can generate a public-private keypair with the genrsa context (the
last number is the keylength in bits):

openssl genrsa -out keypair.pem 2048

To extract the public part, use the rsa context:

openssl rsa -in keypair.pem -pubout -out publickey.crt

Finally, convert the original keypair to PKCS#8 format with the pkcs8
context:

openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out pkcs8.key

Ciao,
Johannes

On Fri, 23 Feb 2024, Gilliard Santos wrote:

> [image: 😀] Hello Git Community, how are you? [image: 😀]
>
> - The Git Bash Terminal Installer includes OpenSSL, and my OpenSSL version
> is *3.1.4 (24 Oct 2023) (Library: OpenSSL 3.1.4 24 Oct 2023)*.
>
> - How can I generate a public or private key using Git Bash?
>
> Thank you all.
>
> --
> You received this message because you are subscribed to the Google Groups "git-for-windows" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to git-for-windo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/git-for-windows/c9ff5975-d240-4e49-b616-f3189230a383n%40googlegroups.com.
>

Konstantin Khomoutov

chưa đọc,
03:18:35 26 thg 2, 202426 thg 2
đến git-for-windows
On Fri, Feb 23, 2024 at 07:31:16AM -0800, Gilliard Santos wrote:

[...]
> - How can I generate a public or private key using Git Bash?
[...]
> This does not seem to be a Git question at all. And the web has a lot of
> answers for this question, e.g
> https://stackoverflow.com/a/44474607/1860823:
>
> You can generate a public-private keypair with the genrsa context (the
> last number is the keylength in bits):
>
> openssl genrsa -out keypair.pem 2048
[...]

To add to the Johannes' response, you might have also meant generating a pair
of SSH keys. If yes, you need the ssh-keygen tool (shipped with GfW); you
might consult, for instance, this doc [1] for details. Or, some GUI tools
can do that, such as puttygen from PuTTY [2].

1. https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
2. https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Trả lời tất cả
Trả lời tác giả
Chuyển tiếp
0 tin nhắn mới