Programing

내 서버의 ECDSA 키 지문이 무엇인지 확인하려면 어떤 명령을 사용해야합니까?

lottogame 2020. 11. 8. 09:10
반응형

내 서버의 ECDSA 키 지문이 무엇인지 확인하려면 어떤 명령을 사용해야합니까?


RSA 키 지문을 보는 방법에 대해 Google 전체에서 볼 수 있지만 ECDSA 지문은 볼 수 없습니다.


잠깐, 찾았어요. 다음 명령을 실행하십시오.

ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub

최근 ssh (OpenSSH_6.0p1, OpenSSL 1.0.0j 2012 년 5 월 10 일)를 사용하여 다음과 같이 스크립팅했습니다.

ssh-keyscan -t ecdsa localhost 2>&1 | grep ecdsa
localhost ecdsa-sha2-nistp256 AAAAE2VlongKey...=

메모:

  • sshd가 사용자 지정 포트에서 실행 -p portNumber되는 경우 ssh-keyscan명령에 ' '를 추가하십시오 )
  • ssh-keyscan(!)가 stderr아니라 에 씁니다. stdout따라서 bash리디렉션 ' 2>&1'(셸에 따라 다를 수 있음)

그것은 ~/.ssh/known_hosts내 테스트를 위해 localhost의 ssh 요청을 승인하기 위해 파일에 추가 한 줄입니다 (주로 ssh를 사용하는 gitolite).


Daniel Böhmer 는 의견에서 확인 합니다 .

  • ssh-keyscan SSH 서버의 전체 공개 키를 제공합니다.
  • 의 출력은 ssh-keygen공개 키 파일의 형식과 거의 동일합니다.
    첫 번째 열 (IP 주소 또는 호스트 이름)을 제거하고이를 저장하거나 ssh-keygen -l지문 있는 파이프에 연결하면됩니다 .

Daniel은 다음과 같이 덧붙입니다.

에 저장된 모든 서버 공개 키의 지문을 표시합니다 ~/.ssh/know_hosts.

cut -d' ' -f2- ~/.ssh/known_hosts | while read line; do echo "$line" | ssh-keygen -lf-; done

내 시스템에서 기본 SHA256 대신 MD5 키를 지정해야합니다.

ssh-keygen -l -E md5 -f /etc/ssh/ssh_host_ecdsa_key.pub

이렇게하면 클라이언트에서 본 오류와 일치하는 형식의 문자열이 출력됩니다.


사용 된 명령

  • 서버에 저장된 공개 호스트 키의 ascii-art 표시 (ssh를 통해 연결하는 서버 측에서 수행) :

    ssh-keygen -l -v -f /etc/ssh/ssh_host_ecdsa_key.pub
    

    -l : 지정된 공개 키 파일의 지문을 표시합니다.

    -v : 시각적 (ascii-art)

    -f : 파일

  • 원격 서버 공개 호스트 키의 ascii-art 표시 (ssh를 통해 연결하는 클라이언트 측에서 수행) :

    ssh -o visualhostkey=yes -o FingerprintHash=md5 <host_server_to_connect>
    

    -o : 옵션

    visualhostkey : 비주얼 (ascii-art)

    FingerprintHash : 사용할 해시 알고리즘

호스트 / 서버의 신뢰성을 확인하기 위해 수행 할 작업

첫째, 1. 서버에서 로컬로 수행해야합니다 (ssh를 통해 연결하려는 서버) : 첫 번째 ascii-art를 제공합니다. 인쇄하거나 사진을 찍으십시오.

둘째, 2. 첫 번째 SSH 연결에서 수행됩니다. 두 번째 ascii-art가 표시됩니다. ascii-art가 동일 하면 "내가 신뢰합니까?"에 예라고 대답 할 수 있습니다. 질문 (예 :) .Are you sure you want to continue connecting (yes/no)

  • 서버 측
$ ssh-keygen -l -v -f /etc/ssh/ssh_host_ecdsa_key.pub
256 2e:a6:b3:27:14:12:0b:79:df:9a:7f:bd:4d:b1:e0:b6   (ECDSA)
+--[ECDSA  256]---+
| .               |
|o o              |
| o + .           |
|  o o .          |
|   . +  S . .    |
|    +  . . . o   |
|   . .o ..o o    |
|    ooo....+     |
|    o= .  E..    |
+-----------------+
  • 고객 입장에서
$ ssh -o visualhostkey=yes -o FingerprintHash=md5 192.168.12.211
The authenticity of host '192.168.12.211 (192.168.12.211)' can't be established.
ECDSA key fingerprint is MD5:2e:a6:b3:27:14:12:0b:79:df:9a:7f:bd:4d:b1:e0:b6.
+---[ECDSA 256]---+
| .               |
|o o              |
| o + .           |
|  o o .          |
|   . +  S . .    |
|    +  . . . o   |
|   . .o ..o o    |
|    ooo....+     |
|    o= .  E..    |
+------[MD5]------+
Are you sure you want to continue connecting (yes/no)? 

좀 더 설명

The first command will display the ascii-art corresponding to the fingerprint of the file you give as input. The file you give as input is the public host key of the server. When a client connect (not only for the first time), the server will sent its public host key. This public host key will be searched in ~/.ssh/known_hosts. If the public key is in the file, then it's ok: the host (server) is known, so we move on to the next step to authentificate the user (user auth is not described in this post). If the public key is not in the file, then the client will compute the fingerprint of this public host key with a hash algorithm (a different hash algo will give a different fingerprint). This fingerprint previously calculated is displayed (along with the ascii-art if corresponding option provided) and you will have to answer yes or no depending on you recognising this fingerprint or no (this fingerprint is the image/hash of the public host key of the server). If you say yes, then the bublic key of the server (not its fingerprint) will be added to the file ~/.ssh/known_hosts.

We can notice that ~/.ssh/known_hosts is under you home (~) directory, because you trust this host (server), but a different user may not trust the same as you. Also, the host public key of the server is not user-dependent, so it is stored in /etc/ssh/.

The second command will display the fingerprint and the ascii-art of the public key received from the host_server_to_connect (according to the hash algo given in options). It is the same as doing only ssh, but with more visual options, so the connection will continue the same way as a normal ssh connexion.

참고URL : https://stackoverflow.com/questions/10060530/what-command-do-i-use-to-see-what-the-ecdsa-key-fingerprint-of-my-server-is

반응형