Friday, June 05, 2015

Cache git credentials (Linux)


While it is possible to store git credentials locally via .netrc, that requires storing them in plain text. Even with 400 permissions, it is an unnecessary risk. I have read references about using GPG for encryption within this file, which increases security, but introduces a new dependency. When changing hosts frequently, local dependencies become highly impractical. Instead, to cache the credentials in memory with an expiration timeout, one hour, for example:

git config --global credential.helper 'cache --timeout=3600'

No comments: