About SSH key generation
If you don't already have an SSH key, you must generate a new SSH key to use for authentication. If you're unsure whether you already have an SSH key, you can check for existing keys. For more information, see "Checking for existing SSH keys."
If you don't want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase.
Einen neuen SSH-Schlüssel erzeugen
-
Öffne TerminalTerminalGit Bash.
-
Füge den folgenden Text ein, und ersetzte dabei Deine GitHub Enterprise Server-E-Mail-Adresse.
$ ssh-keygen -t ed25519 -C "your_email@example.com"
Note: If you are using a legacy system that doesn't support the Ed25519 algorithm, use:
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
This creates a new SSH key, using the provided email as a label.
> Generating public/private algorithm key pair.
-
Wenn die Aufforderung „Enter a file in which to save the key“ (Datei angeben, in der der Schlüssel gespeichert werden soll) angezeigt wird, drücke die Eingabetaste. Dadurch wird der Standard-Speicherort akzeptiert.
> Enter a file in which to save the key (/Users/you/.ssh/id_algorithm): [Press enter]
> Enter a file in which to save the key (/c/Users/you/.ssh/id_algorithm):[Press enter]
> Enter a file in which to save the key (/home/you/.ssh/algorithm): [Press enter]
-
Gib bei der Eingabeaufforderung eine sichere Passphrase ein. For more information, see "Working with SSH key passphrases."
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]
Deinen SSH-Schlüssel zum SSH-Agenten hinzufügen
Before adding a new SSH key to the ssh-agent to manage your keys, you should have checked for existing SSH keys and generated a new SSH key. Wenn Du Deinen SSH-Schlüssel zum Agenten hinzufügst, verwende den standardmäßigen macOS-Befehl 'ssh-add‘ und nicht eine Anwendung, die von macports, homebrew oder einer anderen externen Quelle installiert wurde.
-
Starte den SSH-Agenten im Hintergrund.
$ eval "$(ssh-agent -s)" > Agent pid 59566
Depending on your environment, you may need to use a different command. For example, you may need to use root access by running
sudo -s -H
before starting the ssh-agent, or you may need to useexec ssh-agent bash
orexec ssh-agent zsh
to run the ssh-agent. -
Wenn Sie macOS Sierra 10.12.2 oder höher verwenden, müssen Sie die Datei
~/.ssh/config
bearbeiten, damit automatisch Schlüssel in den ssh-agent geladen und Passphrasen in der Keychain gespeichert werden.-
Überprüfe zunächst, ob Deine
.ssh/config
-Datei am Standardspeicherort vorhanden ist.$ open ~/.ssh/config > The file /Users/you/.ssh/config does not exist.
-
Wenn die Datei nicht existiert, musst Du sie erstellen.
$ touch ~/.ssh/config
-
Open your
~/.ssh/config
file, then modify the file to contain the following lines. If your SSH key file has a different name or path than the example code, modify the filename or path to match your current setup.Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519
Note: If you chose not to add a passphrase to your key, you should omit the
UseKeychain
line.Note: If you see an error like this
/Users/USER/.ssh/config: line 16: Bad configuration option: usekeychain
add an additional config line to your
Host *
section:Host * IgnoreUnknown UseKeychain
-
-
Fügen Sie Ihren privaten SSH-Schlüssel zu ssh-agent hinzu, und speichern Sie Ihre Passphrase in der Keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add -K ~/.ssh/id_ed25519
Note: The
-K
option is Apple's standard version ofssh-add
, which stores the passphrase in your keychain for you when you add an SSH key to the ssh-agent. If you chose not to add a passphrase to your key, run the command without the-K
option.Wenn Sie die Standardversion von Apple nicht installiert haben, tritt möglicherweise ein Fehler auf. Weitere Informationen zum Beheben dieses Fehlers finden Sie unter Fehler: „ssh-add: illegal option -- K““.
-
Add the SSH key to your account on GitHub Enterprise Server. For more information, see "Adding a new SSH key to your GitHub account."
Wenn Sie GitHub Desktop installiert haben, können Sie die Lösung verwenden, um Repositorys zu klonen und um nicht mit SSH-Schlüsseln zu arbeiten.
-
Stellen Sie sicher, dass ssh-agent ausgeführt wird. You can use the "Auto-launching the ssh-agent" instructions in "Working with SSH key passphrases", or start it manually:
# start the ssh-agent in the background $ eval "$(ssh-agent -s)" > Agent pid 59566
-
Fügen Sie Ihren privaten SSH-Schlüssel zu ssh-agent hinzu. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_ed25519
-
Add the SSH key to your account on GitHub Enterprise Server. For more information, see "Adding a new SSH key to your GitHub account."
-
Starte den SSH-Agenten im Hintergrund.
$ eval "$(ssh-agent -s)" > Agent pid 59566
Depending on your environment, you may need to use a different command. For example, you may need to use root access by running
sudo -s -H
before starting the ssh-agent, or you may need to useexec ssh-agent bash
orexec ssh-agent zsh
to run the ssh-agent. -
Fügen Sie Ihren privaten SSH-Schlüssel zu ssh-agent hinzu. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_ed25519
-
Add the SSH key to your account on GitHub Enterprise Server. For more information, see "Adding a new SSH key to your GitHub account."