{"meta":{"title":"SSH 키 암호문 사용","intro":"SSH 키를 보호하고 인증 에이전트를 구성하여 SSH 키를 사용할 때마다 암호를 다시 입력할 필요가 없도록 할 수 있습니다.","product":"인증","breadcrumbs":[{"href":"/ko/authentication","title":"인증"},{"href":"/ko/authentication/connecting-to-github-with-ssh","title":"SSH와 연결"},{"href":"/ko/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases","title":"SSH 키 암호"}],"documentType":"article"},"body":"# SSH 키 암호문 사용\n\nSSH 키를 보호하고 인증 에이전트를 구성하여 SSH 키를 사용할 때마다 암호를 다시 입력할 필요가 없도록 할 수 있습니다.\n\n## SSH 키의 암호 정보\n\nSSH 키를 사용할 경우 누군가가 컴퓨터에 대한 액세스 권한을 얻으면 공격자는 해당 키를 사용하는 모든 시스템에 대한 액세스 권한도 얻을 수 있습니다. 추가 보안 계층을 추가하려면 SSH 키에 암호를 추가할 수 있습니다. 연결할 때마다 암호를 입력하지 않도록 하려면 SSH 에이전트에서 키를 안전하게 캐시할 수 있습니다.\n\n## 암호 추가 또는 변경\n\n다음 명령을 입력하여 키 쌍을 다시 생성하지 않고 기존 프라이빗 키의 암호를 변경할 수 있습니다.\n\n```shell\n$ ssh-keygen -p -f ~/.ssh/id_ed25519\n> Enter old passphrase: [Type old passphrase]\n> Key has comment 'your_email@example.com'\n> Enter new passphrase (empty for no passphrase): [Type new passphrase]\n> Enter same passphrase again: [Repeat the new passphrase]\n> Your identification has been saved with the new passphrase.\n```\n\n키에 이미 암호가 있는 경우 새 암호로 변경하기 전에 암호를 입력하라는 메시지가 표시됩니다.\n\n<div class=\"ghd-tool windows\">\n\n## Git for Windows에서 `ssh-agent` 자동 실행\n\nbash 또는 Git 셸을 열 때 `ssh-agent`를 자동으로 실행할 수 있습니다. 다음 줄을 복사하여 Git 셸의 `~/.profile` 또는 `~/.bashrc` 파일에 붙여넣습니다.\n\n```bash\nenv=~/.ssh/agent.env\n\nagent_load_env () { test -f \"$env\" && . \"$env\" >| /dev/null ; }\n\nagent_start () {\n    (umask 077; ssh-agent >| \"$env\")\n    . \"$env\" >| /dev/null ; }\n\nagent_load_env\n\n# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2=agent not running\nagent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)\n\nif [ ! \"$SSH_AUTH_SOCK\" ] || [ $agent_run_state = 2 ]; then\n    agent_start\n    ssh-add\nelif [ \"$SSH_AUTH_SOCK\" ] && [ $agent_run_state = 1 ]; then\n    ssh-add\nfi\n\nunset env\n```\n\n프라이빗 키가 기본 위치(예: `~/.ssh/id_rsa`) 중 하나에 저장되지 않은 경우 SSH 인증 에이전트에 찾을 위치를 알려야 합니다. ssh-agent에 키를 추가하려면 `ssh-add ~/path/to/my_key`를 입력합니다. 자세한 내용은 [새 SSH 키 생성 및 ssh-agent에 추가](/ko/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)을(를) 참조하세요.\n\n> \\[!TIP]\n> 일정 시간 후에 `ssh-agent`가 키를 잊어버리게 하려면 `ssh-add -t <seconds>`를 실행하여 구성하면 됩니다.\n\n이제 Git Bash를 처음 실행하면 암호를 입력하라는 다음과 같은 메시지가 표시됩니다.\n\n```shell\n> Initializing new SSH agent...\n> succeeded\n> Enter passphrase for /c/Users/YOU/.ssh/id_rsa:\n> Identity added: /c/Users/YOU/.ssh/id_rsa (/c/Users/YOU/.ssh/id_rsa)\n> Welcome to Git (version 1.6.0.2-preview20080923)\n>\n> Run 'git help git' to display the help index.\n> Run 'git help <command>' to display help for specific commands.\n```\n\n로그 아웃하거나 컴퓨터를 종료하거나 프로세스를 종료할 때까지 `ssh-agent` 프로세스가 계속 실행됩니다.\n\n</div>\n\n<div class=\"ghd-tool mac\">\n\n## 키체인에 암구문 저장\n\nOS X El Capitan을 통해 Mac OS X Leopard에서 기본 프라이빗 키 파일이 자동으로 처리됩니다.\n\n* *.ssh/id\\_rsa*\n* *.ssh/identity*\n\n키를 처음 사용할 때 암호를 입력하라는 메시지가 표시됩니다. 키 집합을 사용하여 암호를 저장하도록 선택한 경우 다시 입력할 필요가 없습니다.\n\n그렇지 않은 경우 ssh-agent에 키를 추가할 때 키체인에 암호 구문을 저장할 수 있습니다. 자세한 내용은 [새 SSH 키 생성 및 ssh-agent에 추가](/ko/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent)을(를) 참조하세요.\n\n</div>"}