
개인 키 암호(id_rsa)를 잊어버리려면 일반적으로 다음을 실행합니다.
ssh-add -D # to forget all loaded identities
ssh-add -d # to forget primary identity ($HOME/.ssh/id_rsa)
이제 macOS Sierra v10.12.1에서 다음 오류가 발생합니다.
$ ssh-add -D
All identities removed.
$ ssh-add -d
Could not remove identity "/Users/user/.ssh/id_rsa": agent refused operation
Could not remove identity "/Users/user/.ssh/id_dsa": agent refused operation
나는 운없이 구글을 검색했다!
답변1
Sierra에서도 동일한 문제가 발생했습니다. 제거한 id_rsa
다음 다시 시작해 보십시오 $HOME/.ssh/
(저도 제거했습니다 id_rsa.pub
. 따라서 두 개의 키가사적인그리고공공의). 그것은 내 문제를 해결했습니다.
답변2
내 경우에는 약간 다른 문제가 발생했습니다. 내가 호출했을 때 ssh-add -D
에이전트는 성공한 것처럼 보였고 응답했지만 All identities removed.
실제로는 에이전트 키를 나열할 때 ssh-add -l
원치 않는 키가 계속 나열되었습니다. 물론 에이전트를 사용하여 원격 호스트에 인증하려고 하면 에이전트는 내가 구성한 방법을 사용하여 나에게 메시지를 표시했습니다. 원하지 않는 키에 암호문을 위한 프로그램을 고정합니다. 짜증 나는.
문제의 원인은 내 gpg-agent 데몬이 다음 경로에 있는 파일의 키를 캐시했기 때문입니다 ~/.gnupg/sshcontrol
.
$ cat ~/.gnupg/sshcontrol
# List of allowed ssh keys. Only keys present in this file are used
# in the SSH protocol. The ssh-add tool may add new entries to this
# file to enable them; you may also add them manually. Comment
# lines, like this one, as well as empty lines are ignored. Lines do
# have a certain length limit but this is not serious limitation as
# the format of the entries is fixed and checked by gpg-agent. A
# non-comment line starts with optional white spaces, followed by the
# keygrip of the key given as 40 hex digits, optionally followed by a
# caching TTL in seconds, and another optional field for arbitrary
# flags. Prepend the keygrip with an '!' mark to disable it.
# RSA key added on: 2021-06-03 16:23:25
# Fingerprints: MD5:c1:[elided]:24
# SHA256:+Mj[elided]E4
21[elided]C9 0
# Ed25519 key added on: 2021-06-03 22:11:36
# Fingerprints: MD5:[elided]:24:da
# SHA256:EL[elided]Zs
E0[elided]47 0
해당 키를 삭제하면 ~/.gnupg/sshcontrol
에이전트가 더 이상 사용하지 않는 키에 대한 암호를 요구하지 않고도 원격 호스트에 인증하기 위해 gpg-agent 사용을 재개할 수 있었습니다.
답변3
참조되는 ID가 추가된 ID와 다를 때 이 오류가 발생했습니다. 이 -d
옵션은 특정 키를 제거합니다. 해당 키가 로드되지 않은 경우 제거를 거부합니다. 로드된 키를 확인 ssh-add -l
하고 조표를 확인할 수 있습니다.ssh-keygen -lf <path-to-private-key>
답변4
Ubuntu 18.04에 여전히 이 버그가 있음을 발견했습니다.
큰 노력 없이 ssh-agent에서 원치 않는 키를 제거하는 간단한 방법은 다음과 같습니다.
제거하려는 키를 찾으세요
ssh-add -l 2048 SHA256:qzJYF7AJAJsLsJn7ZFPcJ+w78ZJVoPZI9TzXCq2cf5 .ssh/bad-key.pem (RSA)
~/.ssh 디렉토리로 이동하여 예를 들어 비활성화된 하위 디렉토리를 만듭니다.
cd ~/.ssh mkdir disabled
비활성화하려는 키를 해당 디렉터리로 이동합니다.
mv bad-key.pem disabled/
그게 다야. 해당 키는 더 이상 ssh-agent에서 사용할 수 없지만 필요한 경우 계속 보유하고 다시 추가할 수 있습니다.