기존 공개 / 개인 키 쌍이 있습니다. 개인 키는 암호로 보호되며 암호화는 RSA 또는 DSA 일 수 있습니다. 이 키는 생성 ssh-keygen
하고 일반적으로 아래에 저장 하는 종류 ~/.ssh
입니다.
개인 키의 비밀번호를 변경하고 싶습니다. 표준 유닉스 쉘에서 어떻게해야합니까?
또한 비밀번호를 어떻게 간단하게 제거합니까? 그냥 비워놓 으세요?
답변
기본 DSA 키에서 비밀번호 문구를 변경하려면 다음을 수행하십시오.
$ ssh-keygen -p -f ~/.ssh/id_dsa
그런 다음 프롬프트에서 기존 암호와 새 암호 (2 회)를 제공하십시오. ~/.ssh/id_rsa
RSA 키가있는 경우 사용하십시오 .
더 자세한 정보 man ssh-keygen
:
[...]
SYNOPSIS
ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment]
[-f output_keyfile]
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
[...]
-f filename
Specifies the filename of the key file.
[...]
-N new_passphrase
Provides the new passphrase.
-P passphrase
Provides the (old) passphrase.
-p Requests changing the passphrase of a private key file instead of
creating a new private key. The program will prompt for the file
containing the private key, for the old passphrase, and twice for
the new passphrase.
[...]
답변
SSH 공개 / 개인 키를 제거하십시오.
rm ~/.ssh/id_rsa*
새로운 암호를 선택하여 키 페어를 다시 만듭니다.
ssh-keygen -t rsa -f ~/.ssh/id_rsa
새로 만든 개인 키를 OS X 키 체인에 추가하여 암호를 저장하고 자동으로 잠금 해제를 관리하십시오.
ssh-add -K ~/.ssh/id_rsa
공개 키를 OS X 클립 보드에 복사하여 GitHub 등과 같은 웹 서비스에 추가하십시오.
cat ~/.ssh/id_rsa.pub | pbcopy
새로 만든 공개 키를 ~/.ssh/authorized_keys
원격 서버 파일에 추가하십시오 . 원격 ~/.ssh
폴더 (700) 및 ~/.ssh/authorized_keys
(600) 의 올바른 권한을 확인하십시오 . ssh-copy-id
이 과정을 쉽게 하기 위해를 사용하여 조사 할 수 있습니다 .