Git配置ssh,并实现免密pull, push

  • 生成public/private key pair

    ssh-keygen -t rsa -C "github账号的邮箱"
    
  • 进入存放密钥的目录,复制public key的内容

  • 将public key添加到github上

  • 免密pull, push

    # 在缓存中写入账号密码,接下来15minutes内可免密pull, push
    git config --global credential.helper cache
    
    # 在磁盘中写入账号密码,下次pull, push时直接从磁盘中读取
    git config --global credential.helper store
    # 这种方式的缺点是你的密码是用明文的方式存放在你的 home 目录下
    
  • 第一次pull/push需要输入账号密码,接下来就可以快速的push啦!

  • 删除保存在 cache/store 中的Git账号密码

    # 在root权限下
    git config --system --unset credential.helper
    

想了解配置ssh的详情可移步:云服务器配置ssh登陆(putty + puttygen)

发布了18 篇原创文章 · 获赞 1 · 访问量 3290

猜你喜欢

转载自blog.csdn.net/SJ1551/article/details/100745846