美文网首页
如何生成git 仓库SSH key

如何生成git 仓库SSH key

作者: 沉默紀哖呮肯伱酔 | 来源:发表于2021-07-26 15:07 被阅读0次
    1. 检查SSH key

    输入下面的命令,如果有文件id_rsa.pub 或 id_dsa.pub,则直接进入步骤3将SSH key添加到Git仓库中,否则进入第二步生成SSH key

    ls -al ~/.ssh
    # Lists the files in your .ssh directory, if they exist
    
    1. 生成新的SSH key
    在命令行中输入ssh-keygen -t rsa -C "your_email@example.com"
    

    将新生成的key添加到ssh-agent中:

    # start the ssh-agent in the background
    eval "$(ssh-agent -s)"
    Agent pid 59566
    ssh-add ~/.ssh/id_rsa
    
    1. 将ssh key添加到Git 仓库里边
      输入如下命令直接将SSH key复制到粘贴板中
    mac
    
    pbcopy < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    
    windows
    
    clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    
    linux
    
    sudo apt-get install xclip
    # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
    
    xclip -sel clip < ~/.ssh/id_rsa.pub
    # Copies the contents of the id_rsa.pub file to your clipboard
    

    相关文章

      网友评论

          本文标题:如何生成git 仓库SSH key

          本文链接:https://www.haomeiwen.com/subject/yxcgmltx.html