Wie kann ich Yubikey / U2F-Anmeldeinformationen bei der Authentifizierung über SSH (insbesondere Git) zwischenspeichern?

1006
Mark McDonald

Ich habe mein GitHub-Konto für die Verwendung von U2F mit Yubikey (über SSH) eingerichtet. Da ich jedoch auch eine Git-Bash-Eingabeaufforderung verwende, werde ich jedes Mal, wenn ich mein Terminal verwende, aufgefordert, meinen Sicherheitsschlüssel zu berühren.

Ich verstehe die Beziehung zwischen SSH-Anmeldeinformationen, dem Schlüssel und dem FIDO U2F-Standard nicht ganz, daher bin ich mir nicht sicher, wie ich meine Umgebung so einrichten sollte, dass ich nicht mehr jedes Mal, wenn ich mein Terminal benutze, aufzufordern habe.

Kann ich es so konfigurieren, dass es nur einmal fragt, etwa einmal am Tag oder einmal pro Sitzung oder so etwas?

4
Möglicherweise werden Sie aufgefordert, die Taste zu berühren, wenn ein Profilskript ausgeführt wird. Prüfen Sie `.profile` und` .bashrc` in Ihrem Home-Verzeichnis in Ihrem Git-Terminal auf alles, was mit ssh zu tun hat oder diesen Schlüssel anderweitig benötigt. deed02392 vor 8 Jahren 0

1 Antwort auf die Frage

3
grawity

First of all, U2F is uncacheable by design. It's not simply a password; it's a challenge/response protocol, in which the token receives a different 'challenge' every time, and issues digital signatures without ever revealing its secret keys to the PC (basically like a smartcard). That's where its main strength lies.

The same applies to Yubikey's classic one-time passwords. As the name says, they're one-time, and the server will never accept the same password more than once, nor any password older than an already accepted one.

That being said, there's two things you can do:

  • First, figure out what is asking you for the credentials, because it's definitely not SSH. The U2F support patches haven't been merged into OpenSSH yet, and ssh git@github.com has never asked for any interactive input – it only ever uses SSH keypairs, not password+2fa.

    Similarly, if you're actually pushing over HTTPS and not SSH, there's still no U2F integration in the HTTP authentication as far as I know, so at most you'd be asked for the 6-digit code.

    If you have a full-sized Yubikey, check whether its light is blinking when prompted. It only blinks when waiting for U2F confirmation – if it's steady, it'll send a classic one-time-password instead. And if you can see the Yubikey typing in a long password, that's not U2F.

  • Second, for SSH in general, you can enable OpenSSH's connection caching / multiplexing feature. After you log in to a server, OpenSSH will keep that connection alive for several minutes even after you close the remote shell (i.e. even after Git finishes its transfers).

    To do that, put the following in your ~/.ssh/config:

    Host * ControlMaster auto ControlPath ~/.ssh/S.%r@%h:%p ControlPersist 5m 

    (Older OpenSSH versions don't support ControlPersist, so you can keep the other two options but you'll need to start the connection manually with ssh -fNM git@github.com.)

Das Bestehen der SSH-Verbindung ist eine großartige Lösung, danke. Beachten Sie für zukünftige Leser, dass Sie wirklich sicherstellen möchten, dass der Zugriff auf die ControlPath-Datei sehr eingeschränkt ist. Um den Schaden zu minimieren, der entstehen kann, wenn ein Angreifer die offene Verbindung erhält, stelle ich meine Hostlinie auf `Host github.com` ein Mark McDonald vor 8 Jahren 0