SSH 키를 제거하는 방법?
현재 서버에 이전 SSH 키가 업로드되었습니다. 문제는 ~/.ssh
원본 id_rsa
과 id_rsa.pub
파일 이있는 디렉토리를 잃어 버렸습니다 .
결과적으로 서버에서 이전 SSH 키를 직접 제거하고 새 SSH 키를 업로드하고 싶습니다.
나는 성공하지 않고 다음 명령을 시도했다.
$> ssh-add -D
SSH 키를 완전히 제거하는 방법이 있습니까?
키를 제거 ssh-add -d/-D
하지 않은 경우 적어도 두 가지 버그 보고서가 있습니다 .
- " 데비안 버그 보고서 # 472477 : 메모리
ssh-add -D
에서 SSH 키를 제거하지 않습니다gnome-keyring-daemon
" - " 우분투 :
ssh-add -D
모든 ID를 삭제해도 작동하지 않습니다. 또한 모든 ID가 자동으로 추가되는 이유는 무엇입니까? "
정확한 문제는 다음과 같습니다.
ssh-add -d/-D
그놈 키링에서 수동으로 추가 한 키만 삭제합니다 .
자동으로 추가 된 키를 삭제할 방법이 없습니다.
이것은 원래 버그이며 여전히 존재합니다.예를 들어, 두 개의 서로 다른 GitHub 계정과 연결된 두 개의 서로 다른 자동로드 된 ssh ID (예 : 직장 및 가정)가있는 경우 서로 전환 할 수있는 방법 이 없습니다 . GitHub는 첫 번째 항목과 일치하므로 GitHub의 '홈'사용자로 표시되어 작업중인 프로젝트를 업로드 할 방법이 없습니다.
허용
ssh-add -d
에 적용 할 자동으로로드 키 (그리고ssh-add -t X
대부분의 사용자가 기대하는 동작을 복원 할 자동으로로드 된 키의 수명을 변경).
보다 정확하게 문제에 대해 :
범인은
gpg-keyring-daemon
:
- 그것은 ssh-agent의 정상적인 작동을 방해합니다. 대부분 암호화 된 ssh 키의 암호를 입력 할 수있는 예쁜 상자가 나타납니다.
- 그리고 그것은 당신의
.ssh
디렉토리를 밟아서 발견 한 키를 자동으로 에이전트에 추가합니다.- 그리고 그 키를 삭제할 수 없습니다.
우리는 이것을 어떻게 미워합니까? 인생은 너무 짧습니다.
최신 ssh 클라이언트는 호스트에 연결할 때 ssh-agent의 모든 키를 자동으로 시도하기 때문에 실패가 발생합니다.
너무 많으면 서버가 연결을 거부합니다.
그리고 gnome-keyring-daemon은 ssh-agent가 갖고 싶은 키의 수를 스스로 결정하고 자동로드했으며,이를 삭제하지 않도록하기 위해 건배했습니다.
이 버그는 최근 2 일 전 (2014 년 8 월 21 일) 우분투 14.04.4에서 확인되었습니다.
가능한 해결 방법 :
- 수행
ssh-add -D
모든 삭제 수동으로 추가 키를. 이것은 또한 자동으로 추가 된 키gnome-keyring
를 잠그지 만을 시도 할 때 어쨌든 키 잠금을 해제하도록 요청 하므로 많이 사용되지 않습니다git push
.- 이동 사용자에
~/.ssh
폴더와 백업라는 별도의 폴더에 동일시 할 제외한 모든 키 파일을 이동합니다. 필요한 경우 해마를 열고 키를 삭제할 수도 있습니다.- 이제
git push
문제없이 할 수 있어야합니다 .
다른 해결 방법 :
당신이 정말로하고 싶은 것은
gpg-keyring-daemon
완전히 끄는 것 입니다.
로 이동System --> Preferences --> Startup Applications
하여 "SSH Key Agent (Gnome Keyring SSH Agent)
"상자를 선택 해제하십시오 . 아래로 스크롤하여 찾아야합니다.당신은 여전히를 얻을 수 있습니다
ssh-agent
자동으로 적재 더 키, 당신은 추가 할 SSH-추가를 실행하지 않으며, 당신이 키를 삭제하려는 경우, 당신은 할 수 있습니다 만 지금은 올바로 수행 동작합니다. 상상 해봐.
이 의견은 실제로 다음을 제안합니다.
해결책은
gnome-keyring-manager
시작 하지 않는 것입니다. 프로그램 파일의 실행 권한을 제거하여 마침내 달성하기가 이상해졌습니다.
ssh 관련 작업을 수행하려고하면 다음 오류가 발생합니다.
$ git fetch
no such identity: <ssh key path>: No such file or directory
다음을 사용하여 ssh 에이전트에서 누락 된 ssh 키를 제거 할 수 있습니다.
$ eval `ssh-agent -s` # start ssh agent
$ ssh-add -D <ssh key path> # delete ssh key
Unless I'm misunderstanding, you lost your .ssh
directory containing your private key on your local machine and so you want to remove the public key which was on a server and which allowed key-based login. In that case, it will be stored in the .ssh/authorized_keys
file in your home directory on the server. You can just edit this file with a text editor and delete the relevant line if you can identify it (even easier if it's the only entry!). I hope that key wasn't your only method of access to the server and you have some other way of logging in and editing the file. You can either manually add a new public key to authorised_keys
file or use ssh-copy-id
. Either way, you'll need password auth set up for your account on the server, or some other identity or access method to get to the authorized_keys
file on the server.
ssh-add
adds identities to your ssh agent which handles management of your identities locally and "the connection to the agent is forwarded over SSH remote logins, and the user can thus use the privileges given by the identities anywhere in the network in a secure way." (man page), so I don't think it's what you want in this case. It has no way to get your public key onto a server without you having access to said server via an ssh login as far as I know.
I opened "Passwords and Keys" application in my Unity and removed unwanted keys from Secure Keys -> OpenSSH keys And they automatically had been removed from ssh-agent -l as well.
I can confirm that this bug is still present in Ubuntu 19.04. The workaround suggested by @VonC worked perfectly, summarizing for my version:
- Click on Activities tab on top left corner
- On the search box that comes up, begin typing "startup applications"
- Click on the "Startup Applications" icon
- On the box that pops up, select the gnome key ring manager application (can't remember the exact name on the GUI but it is distinctive enough) and remove it.
What I did next was to try ssh-add -D
again, and after reboot ssh-add -l
told me The agent has no identities. I confirmed that I still had the ssh-agent
daemon running with ps aux | grep agent
. So I added the key I most frequently use with GitHub (ssh-add ~/.ssh/id_ecdsa
) and all is good!
이제 가장 자주 사용되는 리포지토리를 사용하여 정상적인 작업을 수행 할 수 있으며 RSA 키를 사용하는 다른 리포지토리에 액세스해야하는 경우에는 터미널 하나를 전용으로 사용합니다 export GIT_SSH_COMMAND="ssh -i /home/me/.ssh/id_rsa.pub"
. 해결되었습니다! 버그와 해결책을 지적 해 준 크레딧은 @VonC로갑니다.
참고 URL : https://stackoverflow.com/questions/25464930/how-to-remove-a-ssh-key
'Programing' 카테고리의 다른 글
특성으로 Java 8 기본 메소드 : 안전? (0) | 2020.07.22 |
---|---|
.NET : 필요한 구성 설정이 누락되면 어떤 예외가 발생합니까? (0) | 2020.07.22 |
R 프로세스가 사용할 수있는 메모리를 늘리거나 줄입니다. (0) | 2020.07.22 |
Flex / Lex와 Yacc / Bison의 차이점은 무엇입니까? (0) | 2020.07.22 |
“잠금 대기 시간 초과를 초과했습니다. (0) | 2020.07.22 |