서버에서 ssh 키를 제거하는 명령 (또는 한 줄)이 있습니까? ssh-copy-id와 반대되는 것?
Ignatio가 제안했듯이 grep -v
.
다음은 다른 키가 남아 있지 않을 때 파일을 포함하는 키를 제거 some unique string
하거나 authorized_keys
파일을 삭제 하는 예입니다 .
if test -f $HOME/.ssh/authorized_keys; then
if grep -v "some unique string" $HOME/.ssh/authorized_keys > $HOME/.ssh/tmp; then
cat $HOME/.ssh/tmp > $HOME/.ssh/authorized_keys && rm $HOME/.ssh/tmp;
else
rm $HOME/.ssh/authorized_keys && rm $HOME/.ssh/tmp;
fi;
fi
some unique string
제거하려는 키에만있는 것으로 교체 하십시오.
ssh에 대한 oneliner로서 이것은
ssh hostname 'if test -f $HOME/.ssh/authorized_keys; then if grep -v "some unique string" $HOME/.ssh/authorized_keys > $HOME/.ssh/tmp; then cat $HOME/.ssh/tmp > $HOME/.ssh/authorized_keys && rm $HOME/.ssh/tmp; else rm $HOME/.ssh/authorized_keys && rm $HOME/.ssh/tmp; fi; fi'
Linux (SLES) 및 HP-UX에서 테스트되었습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다