OpenSSH

Ansprechpartner

sabine
Mathias

1. TODO

2. Hostschlüssel

2.1. DSA- und ECDSA-Hostschlüssel

2.2. Ed25519- und RSA-Hostschlüssel

2.3. Fingerabdrücke

Neuere OpenSSH-Versionen (in Debian 9) verwenden nicht mehr den Hash-Algorithmus MD5 sondern SHA256. Dies kann mit -E sha256 bzw. -E md5 festgelegt werden.

# ssh-keygen -l -v -f /etc/ssh/ssh_host_(ed25519|rsa)_key
# ssh-keygen -l -v -E md5 -f /etc/ssh/ssh_host_(ed25519|rsa)_key

2.3.1. Ed25519-Hostschlüssel

ED25519

256

MD5

b3:8d:39:94:42:60:cc:b6:ac:53:71:cd:8b:8e:3f:15

+--[ED25519 256]--+
|   oo  o         |
|   .=.. o        |
|   o +.. .       |
|    +.. E.       |
|   o o. S.       |
|  o . .o.*       |
|   . . .= .      |
|      o  .       |
|       .         |
+-----------------+

ED25519

256

SHA256

yT4NrOWa5DLw0d+Fykc/VXpmWALoGxia8hM4v2ahlgE

+--[ED25519 256]--+
|           .     |
|        . . .    |
|     . o +   .   |
|  E + +o..o   . o|
|   . * .S  +   * |
|  . o *= o+ . + +|
|   o =o*++.o . + |
|    Bo+o+.o o    |
|   . =+  .   .   |
+----[SHA256]-----+

2.3.2. RSA-Hostschlüssel

RSA

4096

MD5

6b:bb:9b:44:2d:7a:f5:4b:61:6a:e5:4e:1d:2a:35:4f

+---[RSA 4096]----+
|                 |
|                 |
|                 |
|         .       |
|        S o * E  |
|       o + B B . |
|      . = + * o  |
|       + + = .   |
|        =o  o    |
+------[MD5]------+

RSA

4096

SHA256

2uvwoQesX75dDhqGadKyuAuficI2+eAcJ7ArkzcFHhU

+---[RSA 4096]----+
|    E.           |
|    .            |
|   .             |
|  o              |
|.. o .  S        |
|... ..o=         |
|+=.oo.B.* . .    |
|BXB+.= B.* +     |
|*=X=..ooB.. .    |
+----[SHA256]-----+

2.4. Fingerabdrücke im DNS

Mittels folgender Befehle ermitteln wir die Daten für den SSHFP-Record im DNS (RR):

# ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -r lug-in.de.
lug-in.de. IN SSHFP 4 1 501e5cd63ba2b1174736ee67c9b6f7e99ed8095c
lug-in.de. IN SSHFP 4 2 c93e0dace59ae432f0d1df85ca473f557a665802e81b189af21338bf66a19601
# ssh-keygen -f /etc/ssh/ssh_host_rsa_key -r lug-in.de.
lug-in.de. IN SSHFP 1 1 940ade135b8f0caa489e041ab9028bf0f9698531
lug-in.de. IN SSHFP 1 2 daebf0a107ac5fbe5d0e1a8669d2b2b80b9f89c236f9e01c27b02b9337051e15

Zur Kontrolle (bitte immer die TTL beachten!):

$ dig -t SSHFP lug-in.de
[...]
;; ANSWER SECTION:
lug-in.de.              300     IN      SSHFP   4 1 501E5CD63BA2B1174736EE67C9B6F7E99ED8095C
lug-in.de.              300     IN      SSHFP   1 1 940ADE135B8F0CAA489E041AB9028BF0F9698531
lug-in.de.              300     IN      SSHFP   4 2 C93E0DACE59AE432F0D1DF85CA473F557A665802E81B189AF21338BF 66A19601
lug-in.de.              300     IN      SSHFP   1 1 DAEBF0A107AC5FBE5D0E1A8669D2B2B80B9F89C236F9E01C27B02B93 37051E15

In der Client-Konfiguration kann man jetzt folgendes verwenden:

Host lug-in.de
  VerifyHostKeyDNS yes
  StrictHostKeyChecking yes
  ...

Da wir noch kein DNSSEC verwenden erhält man nur mit ssh -v lug-in.de weitere Informationen:

debug1: Server host key: ssh-ed25519 SHA256:yT4NrOWa5DLw0d+Fykc/VXpmWALoGxia8hM4v2ahlgE
debug1: found 4 insecure fingerprints in DNS
debug1: matching host key fingerprint found in DNS
debug1: Host 'lug-in.de' is known and matches the ED25519 host key.
debug1: Found key in /path/to/known_hosts:xxx

Wenn die Fingerprints dagegen nicht übereinstimmen, erhält man folgende Warnung:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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 a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Please contact your system administrator.
Update the SSHFP RR in DNS with the new host key to get rid of this message.

3. /etc/ssh/sshd_config

Um OpenSSH sicherer zu machen, wird die Server-Konfiguration geändert. Einige Tipps stammen aus dem Howto von bettercrypto.org (siehe oben), andere Sachen sind hier noch zusätzlich erklärt:

4. Scanner

Die Konfiguration von SSH-Servern kann über CryptCheck gescannt werden.


CategoryDocumentation

Dokumentation/SSH (last edited 2018-12-09 21:19:43 by Mathias)