windows环境下 生成公钥和私钥

  1. 上传代码到远程仓库的时候需要秘钥进行验证是否本人上传的。打开Git目录下的Git Bash
    输入ssh-keygen,回车
  1. 可直接不输入路径,使用默认路径(c/Users/Administrator/.ssh/)
  2. 按照提示要输入两次密码,但是如果输入了,每次操作操作git库时都要输入密码,所以选择不输入密码
  3. 密码输入结束后,提示已生成秘钥
  4. 打开c:/Users/Administrator/.ssh/,在文件中,id_rsa是私钥文件,id_rsa.pub是公钥文件
  5. 将公钥文件内容添加到github中的ssh公钥
  6. 回到git bash,输入
ssh -T git@git.oschina.net
  1. 如果显示 'Welcome to Git@OSC, your username!',则表示成功

修改本地的ssh remote url。不用https协议,改用git协议

  1. 查看当前的remote url,可以看到是使用https协议进行访问的
    git remote -v  
  
    orgin https://github.com/xxx/xxx.git(fetch)  
    orgin https://github.com/xxx/xxx.git(push)
  1. 调整url,使用项目的ssh url
    git remote set-url origin git@github.com:xxx/xxx.git

相关文章:

  • 2022-02-13
  • 2021-12-02
  • 2021-10-28
  • 2022-02-09
  • 2021-11-10
  • 2021-11-07
猜你喜欢
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2021-12-22
  • 2021-10-30
相关资源
相似解决方案