GitHub выпустил в публичное превью истекающие учётные данные для gh. Вместо бессрочного OAuth-токена CLI хранит короткоживущий токен доступа и ротируемый refresh-токен и обновляет доступ автоматически — пользователь остаётся залогиненным, а утёкший токен перестаёт работать в течение нескольких часов, а не живёт бесконечно.
Это особенно актуально на фоне атак, в которых злоумышленники добывают токены gh с машин разработчиков и CI.
Как включить
- Для одного входа:
gh auth login --expiring. - Для всех входов:
gh config set expiring_credentials enabled. - Проверить статус и время истечения:
gh auth status. - Если git работает по HTTPS — выполнить
gh auth setup-git, чтобы учётными данными управлялgh; рекомендуется git 2.46 или новее.
Требования и подводные камни
- Нужен GitHub CLI v2.103.0. Работает на github.com и ghe.com, в GitHub Enterprise Server — начиная с GHES 3.23; на старых серверах
ghоткатывается к обычному токену. - Скрипты, которые один раз сохраняют вывод
gh auth token, сломаются после истечения токена — вызывайте команду каждый раз, когда токен нужен. - Существующие входы и вручную заданные токены не меняются, пока вы явно не включите функцию.
GitHub планирует в будущем сделать истекающие токены поведением по умолчанию для новых входов, так что скрипты стоит адаптировать заранее.
GitHub has released expiring credentials for gh in public preview. Instead of a non-expiring OAuth token, the CLI stores a short-lived access token plus a rotating refresh token and renews access automatically — you stay signed in, while a leaked token stops working within hours instead of lasting indefinitely.
That matters given recent attacks in which gh tokens are lifted from developer machines and CI.
How to enable it
- For a single sign-in:
gh auth login --expiring. - For all sign-ins:
gh config set expiring_credentials enabled. - Check status and expiry:
gh auth status. - If git uses HTTPS, run
gh auth setup-gitsoghmanages the credential; git 2.46 or newer is recommended.
Requirements and gotchas
- Requires GitHub CLI v2.103.0. Works on github.com and ghe.com, and on GitHub Enterprise Server from GHES 3.23; on older servers
ghfalls back to a regular token. - Scripts that save the output of
gh auth tokenonce will break when the token expires — call the command each time you need a token. - Existing sign-ins and manually supplied tokens are unchanged unless you opt in.
GitHub plans to make expiring tokens the default for new sign-ins in a future release, so it’s worth adapting scripts now.