windows下配置ssh免密方式操作github代码库

启动git bash工具命令行

1、查看本地是否已经有ssh key

$ ls -al ~/.ssh
如果有将展示类似:
id_dsa.pub
id_ecdsa.pub
id_ed25519.pub
id_rsa.pub

如果有直接执行,第4步骤

2、生成ssh key,并添加到ssh-agent

$  ssh-****** -t rsa -b 4096 -C "[email protected]" 修改成你自己的邮箱地址
出现提示
> Generating public/private rsa key pair
> Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter] #如果不想输入一路回车
> Enter passphrase (empty for no passphrase): [Type a passphrase] #如果不想输入一路回车
> Enter passphrase (empty for no passphrase): [Type a passphrase]#如果不想输入一路回车

验证ssh-agent 是否已在后台运行

$ eval $(ssh-agent -s)
> gent pid 59566

添加key到ssh-agent

$ ssh-add ~/.ssh/id_rsa

经过上述操作本地key已经生成。

3、将key添加到github

  1. windows下在用户文件夹下面生成.ssh文件夹,打开 id_rsa.pub 粘贴里面的字符串

  2. 登录github
    windows下配置ssh免密方式操作github代码库
    然后点击
    windows下配置ssh免密方式操作github代码库
    Click New SSH key or Add SSH key
    windows下配置ssh免密方式操作github代码库
    然后,title随便填写,keys粘贴刚才的key字符串,注意去掉粘贴产生的后面的无用空格
    windows下配置ssh免密方式操作github代码库
    至此添加成功

4、使用

windows下配置ssh免密方式操作github代码库

$ git clone [email protected]

参考链接 github官网