当前位置: 首页 > news >正文

Git 免密认证:Git Credential Helper

提到 Git 免密,也许大多数人会想到 SSH。但是当 SSH 不可用的时候怎么办?

比如你没有提交 SSH 公钥的权限。

又比如自建的 Git,如果所有域名都在 Cloudflare 的保护下,不想暴露 ip 地址,就只能用 https。(PS: 这种情况也可以用 Cloudflare Tunnel,而且需要客户端额外配置,不是很推荐)

Git Credential Helper

Git Credential Helper 就是解决在 HTTPS 协议下 Git 操作时需要频繁输入密码或者 PAT 的痛点。

设置仅需一行代码:

git config --global credential.helper <helper_name>

macOS

git config --global credential.helper osxkeychain

Windows

新版的 Windows Git 应该自动安装了 GCM,无需单独设置。

git config --global credential.helper manager
# 或者
git config --global credential.helper wincred

Linux

如果有桌面环境,可以存到GNOME Keyring 或者 KDE Wallet

git config --global credential.helper libsecret

如果没有,可以看下面的

通用方法

  1. Cache

    默认在内存中持续15分钟,如果有需要可以延长时间。

    git config --global credential.helper cache
    # 一小时
    git config --global credential.helper 'cache --timeout=3600'
    
  2. Store

    这种方法不安全,因为是明文存储,不要在公共环境或者生产环境使用,仅作为最后的手段。

    git config --global credential.helper store
    # 或者指定位置
    git config --global credential.helper 'store --file ~/.my-credentials'
    
  3. GCM: Git Credential Manager

    安装方法见:

    1. https://github.com/git-ecosystem/git-credential-manager/blob/release/docs/install.md

    2. https://docs.github.com/en/get-started/git-basics/caching-your-github-credentials-in-git

    据称只要安装,无需配置即可使用。

    对于Windows 用户来说,只要安装了 GCM,所有的 WSL 均可分享凭证,很方便。

参考资料:

  1. 7.14 Git Tools - Credential Storage
  2. Git credential helpers
http://www.hn-smt.com/news/2301/

相关文章:

  • 类和对象-对象的特性project4
  • 人人聘招聘系统:多端协同的企业招聘解决方案
  • ubuntu操作系统增加swap内存 - Ladisson
  • Ubuntu Netplan
  • python动态加载插件 - ling
  • 2025年混凝土预制管桩设备定做厂家权威推荐榜单:PHC管桩生产设备/PHC管桩生产线/混凝土管桩生产设备源头厂家精选
  • 2025年阻燃pp管厂商权威推荐榜单:阻燃pp管厂商/塑料pp管/pp化工管源头厂家精选
  • rbd元数据
  • 2025 年 pe 板源头厂家最新推荐榜,技术实力与市场口碑深度解析,精选优质企业pp 板 pe 板/耐腐蚀 pe 板/耐磨 pe 板公司推荐
  • ({behavior: smooth}) 在移动端不生效的问题解决 ios不平滑,使用smoothscroll-polyfill(页面平滑滚动)插件
  • [转] 封装超时工具方法
  • 大屏布局总结
  • [转] Promise静态方法汇总 (Promise.try)
  • K8S使用开源CEPH作为后端StorageClass
  • Bcache详解及踩坑记录
  • 从经验到数据:MyEMS 如何推动能源管理的范式升级?
  • 个人微信机器人开发
  • K8S如何查询PVC的已用容量和剩余可用容量
  • MyEMS 的智慧大脑:从能耗建模到预测性维护的全流程技术逻辑
  • Bash 中的 shopt -s globstar:递归 Glob 模式详解 - 教程
  • TPT-X-2025.09 焕新上线!汽车电子测试效率再升级,解决测试痛点!
  • 2025标识标牌公司推荐:权威排行与深度解析
  • 2025年10月OKR管理系统推荐榜:五大工具横向对比与深度解析
  • 2025年广东到澳洲海运服务商权威推荐榜单:到墨尔本海运/到悉尼海运/到布里斯班海运源头公司精选
  • 代码大全-2
  • 如何监控和调优JVM性能?
  • 上海数字营销公司哪家强?2025年度TOP10排行榜揭晓!
  • 中电金信:这些险企在加速构建数智化新范式
  • leetcode|700二叉搜索树中的搜索|938二叉搜索树的范围和|530二叉搜索树的最小绝对差
  • 2025年10月绩效管理咨询公司榜单:五强对比与落地指南 。