使用 `git config --global credential.helper 'cache` 的 git 凭据缓存有多安全?

How secure is git credential caching with `git config --global credential.helper 'cache`?

使用 git HTTPS 凭据缓存与 git config --global credential.helper 'cache 相比使用 git SSH 密钥身份验证安全性如何?

git credential.helper cachedocumentation 说:

The stored credentials never touch the disk, and are forgotten after a configurable timeout. The
cache is accessible over a Unix domain socket, restricted to the current user by filesystem permissions.

我发现您可以使用以下命令查看 HTTPS 缓存凭据 echo url=https://[example.com] | git credential fill。不确定这与使用 SSH 密钥相比的安全隐患。如果其他人通过 SSH 连接到同一设备(作为具有不同 SSH 密钥的不同用户),他们是否也能够查看凭据,或者因为他们是不同的用户,他们将无法以这种方式查看凭据?

考虑到这两种方法,如果有人获得了对您的系统的访问权限并假设了您的用户,他们可以查看密码或 SSH 密钥,那么说 HTTPS 身份验证通常更安全是否正确,因为它会过期在给定时间段后 II) 重启后到期 III) 可以配置为仅针对某些 git 操作的范围权限?

If somebody else SSH-ed into the same device (as a different user with different SSH keys), would they also be able to view the credentials

不,因为正如文档所述,缓存可通过 Unix 域套接字访问,受文件系统权限限制为当前用户。

compare vs. using git SSH key authentication security wise?

SSH 密钥表示您没有输入密码。
要使用 HTTPS 实现同样的效果,最好使用持久缓存,而不是临时缓存,因为您需要在每个会话中输入密码。

最新的是 GCM-core: Git Credential Manager Core
它需要 to be installed, but once git config credential.helper is set to manager-core, it will store the password (for a given URL) in a secure local vault, using libscret 使用 D-Bus 与“秘密服务”通信(gnome-keyringksecretservice 都是秘密服务的实现。)