|
|
(124 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) |
Zeile 1: |
Zeile 1: |
| == What is this all about ? ==
| | '''Fingerabdruck eines SSH-Servers prüfen''' |
| Increasing security by verifying the identity of the machine that you connect to with ssh by eye and with SSHFP in DNS.
| |
|
| |
|
| [http://en.wikipedia.org/wiki/Secure_Shell ssh] allows you to connect to a remote machine with the data between the two machines being encrypted. You can then securely do: command line login, file copy, tunnel other protocols (eg: rsync, X11), ... You authenticate by either typing a password or [https://www.phcomp.co.uk/Tutorials/Unix-And-Linux/ssh-passwordless-login.html key exchange].
| | == Beschreibung == |
| | Die Überprüfung der Authentizität Ihres Servers ist wichtig, wenn Sie sich zum ersten Mal mit ihm verbinden |
|
| |
|
| A big vulnerability is a [http://en.wikipedia.org/wiki/Man-in-the-middle_attack man in the middle attack] where some malevolent snooping entity (Mallory) between you and the remote machine intercepts all traffic, decrypts it & reencrypts before sending it on. Mallory can do this fast enough so that you are not aware of his existance.
| | === Authentizität eines entfernten Hosts === |
| | ; Warum die SSH-Fingerabdruckprüfung wichtig ist |
| | SSH-Verbindungen sind am verwundbarsten, wenn Sie sich zum ersten Mal mit einem Server verbinden |
| | * Nachdem Sie zum ersten Mal eine Verbindung zu einem Server hergestellt haben, speichert der SSH-Client seinen Fingerabdruck |
|
| |
|
| To protect you against this your ssh program checks the remote ssh server's '''fingerprint''' with the fingerprint saved from the last time it connected. If the fingerprint has changed you will be warned and asked if you wish to continue. In [http://en.wikipedia.org/wiki/Openssh openssh] (the ''ssh'' used on most Linux systems) this fingerprint is stored in <tt>$HOME/.ssh/known_hosts</tt>.
| | * Wenn sich dieser Fingerabdruck dann ändert, weil jemand versucht, Sie mit einem bösartigen Server zu verbinden, wird Ihr SSH-Client Sie warnen, dass sich der Fingerabdruck geändert hat |
|
| |
|
| The '''fingerprint''' is a short version of the server's public key; it is easier for you to verify than the full key. It is very hard to spoof another public key with the same fingerprint.
| | Wenn Sie sich zum ersten Mal mit einem Server verbinden, war Ihr Client nicht in der Lage, seinen Fingerabdruck zu protokollieren und zu überprüfen, ob er korrekt ist |
| | * Daher kann ein Angreifer erfolgreich einen Man-in-the-Middle-Angriff durchführen |
| | * Die einzige Möglichkeit, um sicherzustellen, dass Sie sich von Anfang an mit dem richtigen Server verbinden, besteht darin, den Fingerabdruck Ihres SSH-Schlüssels manuell zu überprüfen |
|
| |
|
| == The problem == | | == Fingerabdruck eines SSH-Schlüssels überprüfen == |
| When you connect to a machine for the first time you do not have the fingerprint in your <tt>known_hosts</tt>, so ssh has nothing to compare it to, so it asks you. This page describes ways in which you can do more than blindly say <tt>yes</tt>.
| | Bevor Sie Ihren Fingerabdruck überprüfen können, müssen Sie den dafür verwendeten Algorithmus kennen |
| | * Dieser sollte aus dem Inhalt Ihrer Nachricht hervorgehen |
| | <code>Die Authentizität des Hosts '172.86.75.163 (172.86.75.163)' kann nicht festgestellt werden.ED25519 key fingerprint is SHA256:NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I.This key is not known by any other namesSind Sie sicher, dass Sie die Verbindung fortsetzen möchten (ja/nein/[fingerprint])?</code> |
| | Sie können sehen, dass unser Schlüssel den Algorithmus '''ED25519''' verwendet und mit '''SHA256''' gehasht wird |
| | * Sie sollten sich dies notieren, ebenso wie den Fingerabdruck selbst, in diesem Fall <code>NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I</code> |
|
| |
|
| == Checking a ssh server key fingerprint by eye ==
| | Ihr Schlüsselalgorithmus könnte auch ECDSA, RSA und DSA sein, und Ihr Hashing-Algorithmus könnte MD5 statt SHA sein |
| When you connect to a machine for the first time you will be told that the authenticity can't be established and presented with a key fingerprint to check. Something like this:
| |
|
| |
|
| The authenticity of host 'mint.phcomp.co.uk (78.32.209.33)' can't be established.
| | === Überprüfen des Fingerabdrucks auf dem Server === |
| RSA key fingerprint is 6a:de:e0:af:56:f8:0c:04:11:5b:ef:4d:49:ad:09:23.
| | Loggen Sie sich über eine vertrauenswürdige Methode in Ihren Server ein |
| Are you sure you want to continue connecting (yes/no)? no
| |
|
| |
|
| You might find that the fingerprint is shown in a different format — just keep reading.
| | Führen Sie den Befehl ssh-keygen aus, um den Fingerabdruck Ihres Schlüssels auszulesen |
| | ; SHA256 |
| | ssh-keygen -lf [Datei]] |
|
| |
|
| To be able to check the fingerprint you need to know what it is. You will probably find the <tt>.pub</tt> files in <tt>/etc/ssh/</tt> that contain [https://www.phcomp.co.uk/Tutorials/Unix-And-Linux/ssh-check-server-fingerprint.html#KeyTypes RSA & DSA keys]. This will generate the fingerprints that you can check:
| | ; MD5 |
| | ssh-keygen -E md5 -lf [Datei] |
|
| |
|
| cd /etc/ssh
| | {| class="wikitable options" |
| for file in *sa_key.pub
| | |- |
| do ssh-keygen -lf $file
| | ! !! Datei |
| done
| | |- |
| | | [[ED25519]] || /etc/ssh/ssh_host_ed25519_key.pub |
| | |- |
| | | [[ECDSA]] || /etc/ssh/ssh_host_ecdsa_key.pub |
| | |- |
| | | [[RSA]] || /etc/ssh/ssh_host_rsa_key.pub |
| | |- |
| | | [[DSA]] || /etc/ssh/ssh_host_dsa_key.pub |
| | |} |
|
| |
|
| There is little point in doing this ''after'' you have logged in, a sufficiently ingenious Mallory could modify what the above generates on the fly so that you see what he wants you to see. This needs to be done ''before hand'' and you can then check it with what you see. You might print the fingerprints out and keep them in your briefcase or wallet.
| | ; Beispiel |
| | ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub |
| | 256 SHA256:NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I root@6311ad8b487e6f00018c5cd1 (ED25519) |
|
| |
|
| == Displaying fingerprints in other formats ==
| | Wenn die Ausgabe nicht mit dem Fingerabdruck übereinstimmt, den Sie zuvor notiert haben, '''stellen Sie keine Verbindung zum Server her!''' |
| You might find that the fingerprint is generated in a different format from what you have. This section tells you how, when connecting, you get the <tt>ssh</tt> client to show them in different formats and, on the server, have <tt>ssh-keygen</tt> generate different format references.
| |
|
| |
|
| You may need to mix and match depending on what you have in front of you and where you are able to run commands.
| | [[Kategorie:SSH]] |
| | |
| === Forcing MD5 hash in hexadecimal ===
| |
| This is the format shown above. You can force <tt>ssh</tt> to display this thus:
| |
| $ ssh -o FingerprintHash=md5 host.example.org
| |
| | |
| === SHA256 in base64 ===
| |
| This new format looks as below:
| |
| The authenticity of host 'mint.phcomp.co.uk (78.32.209.33)' can't be established.
| |
| RSA key fingerprint is SHA256:jP0pfKJ9OAXt2F+LM7j3+BMalQ/2Koihl5eH/kli6A4.
| |
| Are you sure you want to continue connecting (yes/no)?
| |
| You can request this with:
| |
| $ ssh -o FingerprintHash=sha256 host.example.org
| |
| You can get <tt>ssh-keygen</tt> to display it:
| |
| ssh-keygen -l -E sha256 -f $file
| |
| This is used in OpenSSH 6.8 & later. The <tt>FingerprintHash</tt> is not available in old versions.
| |
| | |
| == ASCII Art Visual Host Key ==
| |
| This displays the host key in a box and is, hopefully, easier to recognise than a string of numbers. It can be used to display both MD5 and SHA256 keys. It looks like this:
| |
| | |
| The authenticity of host 'mint.phcomp.co.uk (78.32.209.33)' can't be established.
| |
| RSA key fingerprint is SHA256:jP0pfKJ9OAXt2F+LM7j3+BMalQ/2Koihl5eH/kli6A4.
| |
| +---[RSA 2048]----+
| |
| | |
| |
| | |
| |
| | . . |
| |
| | +. . <nowiki>= </nowiki> |
| |
| | . S= o + |
| |
| | .oo+.. o o|
| |
| | E.=***.= + |
| |
| | .=*=BoXo+ |
| |
| | .o+=o=+*o. |
| |
| +----[SHA256]-----+
| |
| Are you sure you want to continue connecting (yes/no)?
| |
| | |
| You can request <tt>ssh</tt> to display it thus:
| |
| $ ssh -o VisualHostKey=yes host.example.org
| |
| | |
| You can request MD5 or SHA256 keys, eg:
| |
| $ ssh -o VisualHostKey=yes -o FingerprintHash=sha256 host.example.org
| |
| | |
| On the server <tt>ssh-keygen</tt> will display when given the <tt>-v</tt> option. Combine this with <tt>-E md5</tt> or <tt>-E sha256</tt> for the fingerprint hash algorithm:
| |
| ssh-keygen -lv -E sha256 -f $file
| |
| | |
| == Checking of a ssh server key via DNS ==
| |
| You can put the server keys fingerprint in DNS (Domain Name System) and get ssh to tell you if what it the two fingerprints match. This is not a guarantee but it makes Mallory's job harder since he needs to spoof DNS as well as ssh, which can be done as few domains yet implement [https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions DNSSEC].
| |
| | |
| === Configuring DNS ===
| |
| Generate the SSHFP fingerprint information to go into DNS:
| |
| | |
| cd /etc/ssh
| |
| for file in *sa_key.pub
| |
| do ssh-keygen -r freshmint.phcomp.co.uk -f $file -g
| |
| done
| |
| freshmint.phcomp.co.uk IN TYPE44 \# 22 02 01 e8fe15b374207a2e6ee99bbbadc87ecd068c17f8
| |
| freshmint.phcomp.co.uk IN TYPE44 \# 22 01 01 e5091496bda76d015e89db0bf925ffb1b9d8facb
| |
| | |
| The above output should be used for bind versions earlier than <tt>9.5.0a1</tt>, after that the <tt>SSHFP</tt> RR type is understood:
| |
| | |
| freshmint.phcomp.co.uk IN SSHFP 02 01 e8fe15b374207a2e6ee99bbbadc87ecd068c17f8
| |
| freshmint.phcomp.co.uk IN SSHFP 01 01 e5091496bda76d015e89db0bf925ffb1b9d8facbEnter the above 2 RR (resource records) into the DNS for the machine. The complete record for the machine looks like: freshmint IN A 78.32.209.33
| |
| IN AAAA 2001:4d48:ad51:2f00::2:2
| |
| IN MX 10 freshmint
| |
| IN SSHFP 1 1 b4b8f2f051a16f57f69590c7c06aeaad039a3882
| |
| IN SSHFP 2 1 ea35c2064a5fc2ec9f51da2e7c790966f9844e59
| |
| mint IN CNAME freshmintCheck that this DNS update is correct with <tt>host -a your.machine.name</tt>. You should see the <tt>SSHFP</tt> lines as above, although with old versions of <tt>host</tt> it may not display properly but like:freshmint.phcomp.co.uk. 259200 IN TYPE44 \# 22 0101b4b8f2f051a16f57f69590c7c06aeaad039a3882
| |
| freshmint.phcomp.co.uk. 259200 IN TYPE44 \# 22 0201ea35c2064a5fc2ec9f51da2e7c790966f9844e59
| |
| | |
| === Using the DNS SSHFP RR ===
| |
| Configure your local ssh client, do this for just you be editing <tt>$HOME/.ssh/config</tt> or system wide <tt>/etc/ssh/ssh_config</tt> (on Minix: <tt>/usr/pkg/etc/ssh/ssh_config</tt>):VerifyHostKeyDNS ask
| |
| | |
| You can also specify this on the command line when connecting. Note how you are told how the DNS fingerprint matches:
| |
| | |
| ssh -o VerifyHostKeyDNS=ask freshmint.phcomp.co.uk
| |
| The authenticity of host 'freshmint.phcomp.co.uk (2001:4d48:ad51:2f00::2:2)' can't be established.
| |
| RSA key fingerprint is 6a:de:e0:af:56:f8:0c:04:11:5b:ef:4d:49:ad:09:23.
| |
| Matching host key fingerprint found in DNS.
| |
| Are you sure you want to continue connecting (yes/no)?If the fingerprint in the DNS does '''not''' match you will see the following — you may have seen similar before, but this is on a first connection:ssh -o VerifyHostKeyDNS=ask freshmint.phcomp.co.uk
| |
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
| |
| @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
| |
| @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
| |
| IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
| |
| Someone could be eavesdropping on you right now (man-in-the-middle attack)!
| |
| It is also possible that the RSA host key has just been changed.
| |
| The fingerprint for the RSA key sent by the remote host is
| |
| 6a:de:e0:af:56:f8:0c:04:11:5b:ef:4d:49:ad:09:23.
| |
| Please contact your system administrator.
| |
| Update the SSHFP RR in DNS with the new host key to get rid of this message.
| |
| The authenticity of host 'freshmint.phcomp.co.uk (2001:4d48:ad51:2f00::2:2)' can't be established.
| |
| RSA key fingerprint is 6a:de:e0:af:56:f8:0c:04:11:5b:ef:4d:49:ad:09:23.
| |
| No matching host key fingerprint found in DNS.
| |
| Are you sure you want to continue connecting (yes/no)?
| |
| | |
| === Other things of interest ===
| |
| Passwordless login with SSH (https://www.phcomp.co.uk/Tutorials/Unix-And-Linux/ssh-passwordless-login.html)
| |
| | |
| === References ===
| |
| #OpenSSH/Cookbook (https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Public_Key_Authentication#Downloading_keys)
| |
| #ssh man page
| |
| #ssh-keygen man page
| |
| #ssh_config man page
| |
| | |
| === Technical bits ===
| |
| You don't really need to understand this bit to use the above; however if you are a technical nerd you will want to know.
| |
| | |
| Key types, these are the first number in the SSHFP RR:
| |
| # RSA — 1 — a public key encryption algorithm invented by Ron Rivest, Adi Shamir and Leonard Adleman (http://en.wikipedia.org/wiki/RSA_%28algorithm%29)
| |
| # DSA — 2 — Digital Signature Algorithm (http://en.wikipedia.org/wiki/Digital_Signature_Algorithm)
| |
| # ECDSA — 3 — Elliptic Curve Digital Signature Algorithm (http://en.wikipedia.org/wiki/Elliptic_Curve_DSA)
| |
| | |
| | |
| Where the key types are used:
| |
| # SSH version 1 — only uses RSA. You should not be using SSH version 1, it is no longer considered to be secure
| |
| # SSH version 2 — RSA & DSA
| |
| # DNS SSHFP RR — RSA, DSA & recently (2012) ECDSA ([http://www.iana.org/assignments/dns- http://www.iana.org/assignments/dns-sshfp-rr-parameters/dns-sshfp-rr-parameters.xml])
| |
| # The second number in the SSHFP RR is the fingerprint type:
| |
| # SHA-1 — 1 — secure hash algorithm 1 a 160-bit message digest ([http://en.wikipedia.org/wiki/Sha-1 http://en.wikipedia.org/wiki/Sha-1])
| |
| # SHA-256 — 2 — secure hash algorithm 2 family a 256-bit message digest (http://en.wikipedia.org/wiki/Sha-256)
| |
| | |
| [[Category:SSH]] | |
| [[Category:Linux]]
| |
| [[Category:Sicherheit]]
| |
| [[Category:Netzwerk]]
| |
Fingerabdruck eines SSH-Servers prüfen
Beschreibung
Die Überprüfung der Authentizität Ihres Servers ist wichtig, wenn Sie sich zum ersten Mal mit ihm verbinden
Authentizität eines entfernten Hosts
- Warum die SSH-Fingerabdruckprüfung wichtig ist
SSH-Verbindungen sind am verwundbarsten, wenn Sie sich zum ersten Mal mit einem Server verbinden
- Nachdem Sie zum ersten Mal eine Verbindung zu einem Server hergestellt haben, speichert der SSH-Client seinen Fingerabdruck
- Wenn sich dieser Fingerabdruck dann ändert, weil jemand versucht, Sie mit einem bösartigen Server zu verbinden, wird Ihr SSH-Client Sie warnen, dass sich der Fingerabdruck geändert hat
Wenn Sie sich zum ersten Mal mit einem Server verbinden, war Ihr Client nicht in der Lage, seinen Fingerabdruck zu protokollieren und zu überprüfen, ob er korrekt ist
- Daher kann ein Angreifer erfolgreich einen Man-in-the-Middle-Angriff durchführen
- Die einzige Möglichkeit, um sicherzustellen, dass Sie sich von Anfang an mit dem richtigen Server verbinden, besteht darin, den Fingerabdruck Ihres SSH-Schlüssels manuell zu überprüfen
Fingerabdruck eines SSH-Schlüssels überprüfen
Bevor Sie Ihren Fingerabdruck überprüfen können, müssen Sie den dafür verwendeten Algorithmus kennen
- Dieser sollte aus dem Inhalt Ihrer Nachricht hervorgehen
Die Authentizität des Hosts '172.86.75.163 (172.86.75.163)' kann nicht festgestellt werden.ED25519 key fingerprint is SHA256:NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I.This key is not known by any other namesSind Sie sicher, dass Sie die Verbindung fortsetzen möchten (ja/nein/[fingerprint])?
Sie können sehen, dass unser Schlüssel den Algorithmus ED25519 verwendet und mit SHA256 gehasht wird
- Sie sollten sich dies notieren, ebenso wie den Fingerabdruck selbst, in diesem Fall
NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I
Ihr Schlüsselalgorithmus könnte auch ECDSA, RSA und DSA sein, und Ihr Hashing-Algorithmus könnte MD5 statt SHA sein
Überprüfen des Fingerabdrucks auf dem Server
Loggen Sie sich über eine vertrauenswürdige Methode in Ihren Server ein
Führen Sie den Befehl ssh-keygen aus, um den Fingerabdruck Ihres Schlüssels auszulesen
- SHA256
ssh-keygen -lf [Datei]]
- MD5
ssh-keygen -E md5 -lf [Datei]
|
Datei
|
ED25519 |
/etc/ssh/ssh_host_ed25519_key.pub
|
ECDSA |
/etc/ssh/ssh_host_ecdsa_key.pub
|
RSA |
/etc/ssh/ssh_host_rsa_key.pub
|
DSA |
/etc/ssh/ssh_host_dsa_key.pub
|
- Beispiel
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
256 SHA256:NTw36MQjDxsHlxC/Xso5yKMlKJu93uYknRx2LEaqk7I root@6311ad8b487e6f00018c5cd1 (ED25519)
Wenn die Ausgabe nicht mit dem Fingerabdruck übereinstimmt, den Sie zuvor notiert haben, stellen Sie keine Verbindung zum Server her!