代码之家  ›  专栏  ›  技术社区  ›  Q_Mlilo

Git,如何生成公钥

  •  16
  • Q_Mlilo  · 技术社区  · 15 年前

    如何使用命令行[git bash]生成公钥(在github/gitlab中使用)。

    下面的命令生成错误 sh.exe": syntax error near unexpected token '('

    我正在使用Windows XP。

    $ ssh-keygen -t rsa -C "xxxx@gmail.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/xxxx/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/xxxx/.ssh/id_rsa.
    Your public key has been saved in /c/Users/xxxx/.ssh/id_rsa.pub.
    The key fingerprint is:
    01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db xxxx@gmail.com
    
    2 回复  |  直到 8 年前
        1
  •  34
  •   Residuum    11 年前

    要运行的命令只是

    ssh-keygen -t rsa -C "you@example.com"
    

    脚本第2行开始的其余部分都是ssh keygen的输出。

    并将您的电子邮件地址替换为your@example.com。

    看看 manual for ssh-keygen 寻找其他选项。您可能应该通过添加 -b 4096 到选项列表。

        2
  •  2
  •   Hazarapet Tunanyan    10 年前

    这是命令

    ssh-keygen -t rsa -b 4096 -C "[your github's email]"
    # Creates a new ssh key
    # Generating public/private rsa key pair.
    

    这将为您生成一个密钥。您必须复制该密钥并将其插入Github的帐户(仅一次)。

    Steps how to do It

    推荐文章