Skip to content
Snippets Groups Projects
Commit 401f9e3e authored by morit02's avatar morit02
Browse files

Add SSH Key commands/info

- How to create a SSH Key
- How to use a SSH Key for authentication
parent d849bdc6
No related branches found
No related tags found
No related merge requests found
......@@ -965,3 +965,55 @@ In diesem Fall gibt es bereits ein **lokales** Git Repository auf dem Gerät, da
## SSH Authentifizierung
Anstatt für jeden Zugriff auf das remote Repository immer den jeweiligen **Benutzer** und das zugehörige **Password** einzugeben, kann ein **SSH Key** verwendet werden.\
Dazu wird auf dem **lokalen Gerät** ein **SSH Key erstellt**. (Es werden zwei Keys erstellt: ein **öffentlicher** (public) und ein **privater** (private) Schlüssel)\
Der **öffentliche** Schlüssel wird auf der **Plattform** für die remote Repository **hinterlegt**.
**Folgende Schritte sind notwendig:**
1. Erstellen eines SSH Keys
```
ssh-keygen -t ed25519 -C "<E-Mail Adresse>" -f ~/.ssh/id_example
```
> Es wird ein **öffentlicher** (public - `.pub`) und ein **privater** (private) Schlüssel erstellt.\
> **Optionen:**
> - `-t` zum angeben des verwendeten **SSH Typen** - [SSH Typen für GitLab](https://docs.gitlab.com/ee/user/ssh.html#supported-ssh-key-types)
> - `-C` zum hinzufügen eines **Kommentars** (zum Beispiel die genutzte E-Mail Adresse auf der Plattform)
> - `-f` zum festlegen des **Speicherortes** und **Names** des Keys (hier `id_example`)
2. **Privaten** (private) SSH Key zum ssh-agent hinzufügen
- SSH-Agent starten
```
eval $(ssh-agent -s)
```
- **Privaten** (private) SSH Key hinzufügen
```
ssh-add ~/.ssh/id_example
```
3. SSH-Client konfigurieren (bei mehreren SSH-Keys)
- Bearbeiten des `~/.ssh/config` Dokuments
```
# Beispiel Konfiguration für GitLab
HOST gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_example
```
4. **Öffentlichen** (public) SSH Key zur Plattform hinzufügen\
**Schritte für GitLab:**
- `Edit profile`
- `SSH Keys`
- `Add new key`
- Einfügen des **öffentlichen** (public) Key mit SSH Typen\
Beispiel: `ssh-ed25519 AA..`
- `Add key`
5. Repository mit SSH clonen\
Um den SSH Key zu verwenden, muss das Repository über SSH geclont werden.\
Die aktuelle remote URL kann mit dem folgenden Befehl angezeigt werden:
```
git remote -v
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment