본문 바로가기
Tip

[Git] Credential Helper, 자격 증명 헬퍼란?

by 너드나무 2024. 11. 28.
반응형

Git 자격 증명 헬퍼(Credential Helper)란?

Git 자격 증명 헬퍼는 사용자의 자격 증명을 관리하여, 인증 과정을 간소화하는 기능입니다.
credential.helper 옵션 중 store는 자격 증명로컬 파일에 저장하는 방식으로 동작합니다.

  • 주요 기능
    1. 자격 증명을 디스크에 저장.
    2. 이후 인증 시 저장된 자격 증명을 자동으로 사용.
    3. 저장된 자격 증명은 명시적으로 삭제하기 전까지 유지.

git-credential-store, git-scm


credential.helper store의 사용 방법

  • 기본 설정
    • --global
      • 사용자 전체 설정. 현재 사용자에 대해 모든 Git 리포지토리에 적용.
    • credential.helper store
      • 자격 증명을 저장하고 필요 시 자동으로 사용.
  • 처음 인증 시 자격 증명 입력
    • Git이 원격 저장소와 통신할 때 사용자 이름과 비밀번호를 입력해야 합니다.
  • 자격 증명 저장
    • credential.helper store가 설정되어 있다면, 자격 증명이 ~/.git-credentials 파일에 저장됩니다.
    • 이후 인증 과정 자동화
# credential.helper store를 설정
$ git config --global credential.helper store

# 처음 인증 시 자격 증명 입력
$ git push origin main
Username for 'https://github.com': your-username
Password for 'https://your-username@github.com': your-password

# 자격 증명 저장
## Linux/macOS: ~/.git-credentials
## Windows: %USERPROFILE%\.git-credentials
$ cat ~/.git-credentials
https://your-username:your-password@github.com

# 자격 증명 삭제
$ rm ~/.git-credentials

장점과 한계

  1. 장점
    1. 편리성
      1. 한 번 입력한 자격 증명을 기억하여, 반복적인 인증 과정을 제거.
    2. 단순성
      1. 설정과 사용법이 간단하며, 초보자도 쉽게 적용 가능.
    3. 로컬 저장소 사용 가능
      1. 인터넷 연결이 없어도 동작.
  2. 한계
    1. 보안 취약성
      1. 자격 증명이 암호화되지 않은 평문으로 저장
      2. 보안에 민감한 환경에서는 적합하지 않을 수 있음.
    2. 공유 환경 위험
      1. 공유 PC나 다중 사용자 시스템에서는 부적절하게 사용될 가능성.

 

 

Git - git-credential-store Documentation

If not set explicitly with --file, there are two files where git-credential-store will search for credentials in order of precedence: ~/.git-credentials User-specific credentials file. $XDG_CONFIG_HOME/git/credentials Second user-specific credentials file.

git-scm.com

728x90
반응형