Skip to content

Commit bc7ee48

Browse files
authored
Merge pull request #84 from max123kl/Chapter-7-14
Datei credentials.asc übersetzt
2 parents 8d0031c + 7659d43 commit bc7ee48

File tree

3 files changed

+93
-93
lines changed

3 files changed

+93
-93
lines changed

book/07-git-tools/sections/credentials.asc

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,47 @@
33

44
(((credentials)))
55
(((git commands, credential)))
6-
If you use the SSH transport for connecting to remotes, it's possible for you to have a key without a passphrase, which allows you to securely transfer data without typing in your username and password.
7-
However, this isn't possible with the HTTP protocolsevery connection needs a username and password.
8-
This gets even harder for systems with two-factor authentication, where the token you use for a password is randomly generated and unpronounceable.
9-
10-
Fortunately, Git has a credentials system that can help with this.
11-
Git has a few options provided in the box:
12-
13-
* The default is not to cache at all.
14-
Every connection will prompt you for your username and password.
15-
* The ``cache'' mode keeps credentials in memory for a certain period of time.
16-
None of the passwords are ever stored on disk, and they are purged from the cache after 15 minutes.
17-
* The ``store'' mode saves the credentials to a plain-text file on disk, and they never expire.
18-
This means that until you change your password for the Git host, you won't ever have to type in your credentials again.
19-
The downside of this approach is that your passwords are stored in cleartext in a plain file in your home directory.
20-
* If you're using a Mac, Git comes with an ``osxkeychain'' mode, which caches credentials in the secure keychain that's attached to your system account.
21-
This method stores the credentials on disk, and they never expire, but they're encrypted with the same system that stores HTTPS certificates and Safari auto-fills.
22-
* If you're using Windows, you can install a helper called ``Git Credential Manager for Windows.''
23-
This is similar to the ``osxkeychain'' helper described above, but uses the Windows Credential Store to control sensitive information.
24-
It can be found at https://github.com/Microsoft/Git-Credential-Manager-for-Windows[].
25-
26-
You can choose one of these methods by setting a Git configuration value:
6+
Wenn Sie den SSH-Transport für die Verbindung zu Remotes verwenden, ist es möglich, dass Sie einen Schlüssel ohne Passwort verwenden. Damit können Sie Daten sicher übertragen, ohne Ihren Benutzernamen und ein Passwort einzugeben.
7+
Mit den HTTP-Protokollen ist das aber nicht möglichjede Verbindung benötigt einen Benutzernamen und ein Passwort.
8+
Noch schwieriger wird das bei Systemen mit Zwei-Faktor-Authentifizierung, bei denen das Token, das Sie für ein Kennwort verwenden, zufällig generiert wird und nicht ausgeprochen werden kann.
9+
10+
Glücklicherweise hat Git ein Anmeldesystem, das hier weiter helfen kann.
11+
Git hat ein paar Optionen im Angebot:
12+
13+
* Standardmäßig wird überhaupt nicht zwischengespeichert.
14+
Bei jeder Verbindung wird nach Ihrem Benutzernamen und Passwort gefragt.
15+
* Der „Cache“-Modus hält die Anmeldedaten für eine gewisse Zeitspanne im Zwischenspeicher.
16+
Keines der Passwörter wird jemals auf der Festplatte abgelegt und nach 15 Minuten werden sie aus dem Cache gelöscht.
17+
* Der „Speicher“-Modus speichert die Zugangsdaten in einer Klartextdatei auf der Festplatte, und sie verfallen nie.
18+
Das bedeutet, dass Sie Ihre Anmeldedaten nie wieder eingeben müssen, bis Sie Ihr Passwort für den Git-Host ändern.
19+
Der Nachteil dieses Ansatzes ist, dass Ihre Passwörter im Klartext in einer einfachen Datei in Ihrem Homeverzeichnis gespeichert werden.
20+
* Wenn Sie einen Mac verwenden, verfügt Git über einen „osxkeychain“-Modus, der die Anmeldeinformationen im sicheren Schlüsselbund, der an Ihr Systemkonto angehängt ist, zwischenspeichert.
21+
Diese Methode speichert die Zugangsdaten, ohne Laufzeitbegrenzung auf der Festplatte. Sie werden mit dem gleichen Verfahren verschlüsselt, das auch HTTPS-Zertifikate und Safari-Automatiken verwaltet.
22+
* Wenn Sie Windows verwenden, können Sie das Hilfsprogramm „Git Credential Manager for Windows“ installieren.
23+
Dieses Programm ähnelt dem oben beschriebenen "osxkeychain"-Modus, verwendet jedoch den „Windows Credential Store“ zur Kontrolle sensibler Informationen.
24+
Es ist unter https://github.com/Microsoft/Git-Credential-Manager-for-Windows[] zu finden.
25+
26+
Sie können eine dieser Methoden durch Setzen eines Git-Konfigurationswertes wählen:
2727

2828
[source,console]
2929
----
3030
$ git config --global credential.helper cache
3131
----
3232

33-
Some of these helpers have options.
34-
The ``store'' helper can take a `--file <path>` argument, which customizes where the plain-text file is saved (the default is `~/.git-credentials`).
35-
The ``cache'' helper accepts the `--timeout <seconds>` option, which changes the amount of time its daemon is kept running (the default is ``900'', or 15 minutes).
36-
Here's an example of how you'd configure the ``store'' helper with a custom file name:
33+
Einige dieser Hilfsmittel haben Optionen.
34+
Der „store“-Assistent kann das Argument `--file <path>` benutzen, das den Speicherort der Klartextdatei anpasst (der Standard ist `~/.git-credentials`).
35+
Der „cache“-Assistent akzeptiert die Option `--timeout <seconds>`, welche die Zeitspanne ändert, in der der Dämon läuft (die Vorgabe ist „900“, oder 15 Minuten).
36+
Hier folgt ein Beispiel, wie Sie der „store“-Assistent mit einem benutzerdefinierten Dateinamen konfigurieren könnten:
3737

3838
[source,console]
3939
----
4040
$ git config --global credential.helper 'store --file ~/.my-credentials'
4141
----
4242

43-
Git even allows you to configure several helpers.
44-
When looking for credentials for a particular host, Git will query them in order, and stop after the first answer is provided.
45-
When saving credentials, Git will send the username and password to *all* of the helpers in the list, and they can choose what to do with them.
46-
Here's what a `.gitconfig` would look like if you had a credentials file on a thumb drive, but wanted to use the in-memory cache to save some typing if the drive isn't plugged in:
43+
Mit Git können Sie auch mehrere Assistenten konfigurieren.
44+
Wenn Sie nach Anmeldeinformationen für einen bestimmten Host suchen, fragt Git diese der Reihe nach ab und stoppt nach der ersten, erhaltenen Antwort.
45+
Beim Speichern der Zugangsdaten sendet Git den Benutzernamen und das Passwort an *alle* Assistenten der Liste, diese entscheiden, was damit zu machen ist.
46+
So würde eine `.gitconfig` aussehen, wenn Sie eine Datei mit Zugangsdaten auf einem USB-Stick hätten, aber den Zwischenspeicher nutzen wollten, um sich die Eingabe zu sparen, wenn das Laufwerk nicht angeschlossen ist:
4747

4848
[source,ini]
4949
----
@@ -52,14 +52,14 @@ Here's what a `.gitconfig` would look like if you had a credentials file on a th
5252
helper = cache --timeout 30000
5353
----
5454

55-
==== Under the Hood
55+
==== Unter der (Motor-)Haube
5656

57-
How does this all work?
58-
Git's root command for the credential-helper system is `git credential`, which takes a command as an argument, and then more input through stdin.
57+
Wie funktioniert das alles?
58+
Der Hauptbefehl für das Anmelde-System ist `git credential`, der einen Befehl als Argument und dann weitere Eingaben über stdin (Standardeingabe=Tastatur) entgegennimmt.
5959

60-
This might be easier to understand with an example.
61-
Let's say that a credential helper has been configured, and the helper has stored credentials for `mygithost`.
62-
Here's a session that uses the ``fill'' command, which is invoked when Git is trying to find credentials for a host:
60+
Mit einem Beispiel ist das vielleicht leichter verständlich.
61+
Nehmen wir an, dass ein Assistent für die Anmeldung konfiguriert wurde und er Anmeldedaten für `mygithost` gespeichert hat.
62+
Die folgende Sitzung verwendet den Befehl „fill“, der aufgerufen wird, wenn Git versucht, Zugangsdaten für einen Host zu finden:
6363

6464
[source,console]
6565
----
@@ -83,39 +83,39 @@ username=bob
8383
password=s3cre7
8484
----
8585

86-
<1> This is the command line that initiates the interaction.
87-
<2> Git-credential is then waiting for input on stdin.
88-
We provide it with the things we know: the protocol and hostname.
89-
<3> A blank line indicates that the input is complete, and the credential system should answer with what it knows.
90-
<4> Git-credential then takes over, and writes to stdout with the bits of information it found.
91-
<5> If credentials are not found, Git asks the user for the username and password, and provides them back to the invoking stdout (here they're attached to the same console).
86+
<1> Diese Befehlszeile leitet die eigentliche Interaktion ein.
87+
<2> Das Anmeldesystem wartet auf die Eingabe von stdin.
88+
Wir geben das „Protokoll“ und den „Hostnamen“ ein.
89+
<3> Eine leere Zeile signalisiert, dass die Eingabe vollständig ist und das Anmeldesystem sollte mit dem antworten, was ihm bekannt ist.
90+
<4> Dann übernimmt das Programm Git-Credential und gibt auf stdout die gefundenen Informationen aus.
91+
<5> Falls keine Anmeldeinformationen gefunden werden, fragt Git den Benutzer nach dem Benutzernamen und dem Kennwort und gibt sie an den aufrufenden stdout zurück (hier sind sie an dieselbe Konsole angeschlossen).
9292

93-
The credential system is actually invoking a program that's separate from Git itself; which one and how depends on the `credential.helper` configuration value.
94-
There are several forms it can take:
93+
Das Anmeldesystem ruft in Wirklichkeit ein Programm auf, das von Git selbst unabhängig ist und bei dem der Konfigurationswert `credential.helper` bestimmt, was und auf welche Weise es aufgerufen wird.
94+
Es kann unterschiedliche Varianten anbieten:
9595

9696
[options="header"]
9797
|======
98-
| Configuration Value | Behavior
99-
| `foo` | Runs `git-credential-foo`
100-
| `foo -a --opt=bcd` | Runs `git-credential-foo -a --opt=bcd`
101-
| `/absolute/path/foo -xyz` | Runs `/absolute/path/foo -xyz`
102-
| `!f() { echo "password=s3cre7"; }; f` | Code after `!` evaluated in shell
98+
| Konfiguration-Wert | Verhalten
99+
| `foo` | läuft als `git-credential-foo`
100+
| `foo -a --opt=bcd` | läuft als `git-credential-foo -a --opt=bcd`
101+
| `/absolute/path/foo -xyz` | läuft als `/absolute/path/foo -xyz`
102+
| `!f() { echo "password=s3cre7"; }; f` | Code nach `!` wird in der Shell ausgewertet
103103
|======
104104

105-
So the helpers described above are actually named `git-credential-cache`, `git-credential-store`, and so on, and we can configure them to take command-line arguments.
106-
The general form for this is ``git-credential-foo [args] <action>.''
107-
The stdin/stdout protocol is the same as git-credential, but they use a slightly different set of actions:
105+
Die oben beschriebenen Hilfsprogramme heißen also eigentlich `git-credential-cache`, `git-credential-store` usw. und wir können sie so konfigurieren, dass sie Befehlszeilenargumente übernehmen.
106+
Die allgemeine Form dafür ist „git-credential-foo [Argument] <Aktion>“.
107+
Das stdin/stdout-Protokoll ist das gleiche wie beim Anmeldesystem, aber sie verwenden einen etwas anderen Befehls-Satz:
108108

109-
* `get` is a request for a username/password pair.
110-
* `store` is a request to save a set of credentials in this helper's memory.
111-
* `erase` purge the credentials for the given properties from this helper's memory.
109+
* `get` ist die Abfrage nach einem Benutzernamen/Passwort-Paar.
110+
* `store` ist die Aufforderung, einen Satz von Anmeldeinformationen im Speicher dieses Assistenten zu hinterlegen.
111+
* `erase` löscht die Anmeldeinformationen für die angegebenen Einstellungen aus dem Speicher dieses Assistenten.
112112

113-
For the `store` and `erase` actions, no response is required (Git ignores it anyway).
114-
For the `get` action, however, Git is very interested in what the helper has to say.
115-
If the helper doesn't know anything useful, it can simply exit with no output, but if it does know, it should augment the provided information with the information it has stored.
116-
The output is treated like a series of assignment statements; anything provided will replace what Git already knows.
113+
Für die `store` und `erase` Aktionen ist keine Reaktion erforderlich (Git ignoriert sie ohnehin).
114+
Für die Aktion `get` ist Git allerdings stark darauf bedacht, was der Assistent sagt.
115+
Wenn das Hilfsprogramm nichts Sinnvolles kennt, kann es einfach ohne Ausgabe abbrechen. Weiß es aber etwas, sollte es die bereitgestellten Informationen mit den gespeicherten Informationen ergänzen.
116+
Die Ausgabe wird wie eine Reihe von Assignment-Statements behandelt. Alles, was zur Verfügung gestellt wird, ersetzt das, was Git bereits kennt.
117117

118-
Here's the same example from above, but skipping git-credential and going straight for git-credential-store:
118+
Hier ist das gleiche Beispiel von oben, aber ohne das Git-Anmeldesystem und direkt zu `git-credential-store`:
119119

120120
[source,console]
121121
----
@@ -132,52 +132,52 @@ username=bob <3>
132132
password=s3cre7
133133
----
134134

135-
<1> Here we tell `git-credential-store` to save some credentials: the username ``bob'' and the password ``s3cre7'' are to be used when `https://mygithost` is accessed.
136-
<2> Now we'll retrieve those credentials.
137-
We provide the parts of the connection we already know (`https://mygithost`), and an empty line.
138-
<3> `git-credential-store` replies with the username and password we stored above.
135+
<1> Hier weisen wir `git-credential-store` an, einige Anmeldedaten zu speichern: der Benutzername „bob“ und das Passwort „s3cre7“ sollen verwendet werden, wenn auf `https://mygithost` zugegriffen wird.
136+
<2> Jetzt rufen wir diese Anmeldedaten ab.
137+
Wir geben die bereits bekannten Teile der Internetadresse (`https://mygithost`) und eine leere Zeile ein.
138+
<3> `git-credential-store` antwortet mit dem Benutzernamen und dem Passwort, die wir beide oben gespeichert haben.
139139

140-
Here's what the `~/git.store` file looks like:
140+
So sieht die Datei `~/git.store` jetzt aus:
141141

142142
[source,ini]
143143
----
144144
https://bob:s3cre7@mygithost
145145
----
146146

147-
It's just a series of lines, each of which contains a credential-decorated URL.
148-
The `osxkeychain` and `wincred` helpers use the native format of their backing stores, while `cache` uses its own in-memory format (which no other process can read).
147+
Sie besteht nur aus einer Reihe von Zeilen, von denen jede eine mit einem Anmeldeinformationen versehene URL enthält.
148+
Die Assistenten `osxkeychain` und `wincred` verwenden das native Format ihrer Zwischenspeicher, während `cache` ein eigenes Speicherformat verwendet (das kein anderer Prozess lesen kann).
149149

150-
==== A Custom Credential Cache
150+
==== Benutzerdefinierter Cache für Anmeldeinformationen.
151151

152-
Given that `git-credential-store` and friends are separate programs from Git, it's not much of a leap to realize that _any_ program can be a Git credential helper.
153-
The helpers provided by Git cover many common use cases, but not all.
154-
For example, let's say your team has some credentials that are shared with the entire team, perhaps for deployment.
155-
These are stored in a shared directory, but you don't want to copy them to your own credential store, because they change often.
156-
None of the existing helpers cover this case; let's see what it would take to write our own.
157-
There are several key features this program needs to have:
152+
Angenommen, dass `git-credential-store` und seine Verwandten von Git getrennte Programme sind, dann ist es kein großer Schritt, zu erkennen, dass _jedes_ Programm ein Hilfsprogramm für die Git-Anmeldung sein kann.
153+
Die von Git bereitgestellten Assistenten decken viele gewöhnliche Anwendungsfälle ab, aber nicht alle.
154+
Nehmen wir zum Beispiel an, Ihr Team hat einige Anmeldedaten, die dem gesamten Team zur Verfügung gestellt werden sollen, eventuell für die Entwicklung.
155+
Diese werden in einem freigegebenen Verzeichnis gespeichert, aber Sie möchten sie nicht in Ihr eigenes Anmeldesystem kopieren, da sie sich häufig ändern.
156+
Keines der vorhandenen Hilfsprogramme ist auf diesen Fall anwendbar; schauen wir mal, was nötig wäre, um unser Eigenes zu schreiben.
157+
Dieses Programm muss mehrere Schlüsselfunktionen haben:
158158

159-
. The only action we need to pay attention to is `get`; `store` and `erase` are write operations, so we'll just exit cleanly when they're received.
160-
. The file format of the shared-credential file is the same as that used by `git-credential-store`.
161-
. The location of that file is fairly standard, but we should allow the user to pass a custom path just in case.
159+
. Die einzige Aktion, auf die wir achten müssen, ist `get`. Die Aktionen `store` und `erase` sind Schreiboperationen, also werden wir sie einfach sauber beenden, sobald sie auftauchen.
160+
. Das Dateiformat der Datei für die gemeinsamen Anmeldedaten ist das gleiche wie es von `git-credential-store` verwendet wird.
161+
. Der Speicherort dieser Datei ist eigentlich standardisiert, aber wir sollten es dem Benutzer erlauben, einen benutzerdefinierten Pfad anzugeben, nur für den Fall, dass er es wünscht.
162162

163-
Once again, we'll write this extension in Ruby, but any language will work so long as Git can execute the finished product.
164-
Here's the full source code of our new credential helper:
163+
Noch einmal zur Erinnerung: Wir werden diese Erweiterung in Ruby schreiben, aber jede Programmiersprache wird funktionieren, solange Git das fertige Produkt ausführen kann.
164+
Hier ist der vollständige Quellcode unseres neuen Anmeldehelfers:
165165

166166
[source,ruby]
167167
--------
168168
include::../git-credential-read-only[]
169169
--------
170170

171-
<1> Here we parse the command-line options, allowing the user to specify the input file.
172-
The default is `~/.git-credentials`.
173-
<2> This program only responds if the action is `get` and the backing-store file exists.
174-
<3> This loop reads from stdin until the first blank line is reached.
175-
The inputs are stored in the `known` hash for later reference.
176-
<4> This loop reads the contents of the storage file, looking for matches.
177-
If the protocol and host from `known` match this line, the program prints the results to stdout and exits.
171+
<1> Hier parsen wir die Befehlszeilenoptionen und erlauben dem Benutzer, die Eingabedatei zu spezifizieren.
172+
Die Vorgabe ist `~/.git-credentials`.
173+
<2> Dieses Programm antwortet nur, wenn die Aktion `get` lautet und die Backup-Speicherdatei existiert.
174+
<3> Die Schleife hier, liest von stdin, bis die erste leere Zeile erkannt wird.
175+
Die Eingaben werden im Hash `known` zur späteren Referenz gespeichert.
176+
<4> Die Schleife hier, liest den Inhalt der Speicherdatei und sucht nach Übereinstimmungen.
177+
Wenn die Protokolldaten und der Host mit `known` in dieser Zeile übereinstimmen, gibt das Programm die Ergebnisse auf stdout aus und beendet sich.
178178

179-
We'll save our helper as `git-credential-read-only`, put it somewhere in our `PATH` and mark it executable.
180-
Here's what an interactive session looks like:
179+
Wir speichern unser Hilfsprogramm als `git-credential-read-only`, legen es irgendwo in unserem `PATH` ab und markieren es als ausführbar.
180+
So sieht dann eine interaktive Sitzung aus:
181181

182182
[source,console]
183183
----
@@ -191,11 +191,11 @@ username=bob
191191
password=s3cre7
192192
----
193193

194-
Since its name starts with ``git-'', we can use the simple syntax for the configuration value:
194+
Da der Name mit „git-“ beginnt, können wir die einfache Syntax für den Konfigurationswert verwenden:
195195

196196
[source,console]
197197
----
198198
$ git config --global credential.helper 'read-only --file /mnt/shared/creds'
199199
----
200200

201-
As you can see, extending this system is pretty straightforward, and can solve some common problems for you and your team.
201+
Wie Sie sehen, ist die Erweiterung dieses Systems ziemlich unkompliziert und kann einige typische Probleme für Sie und Ihr Team lösen.

0 commit comments

Comments
 (0)