如何生成git 仓库SSH key

  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
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容