Zum Inhalt

SSH

Polycrate bietet native SSH-Integration für schnellen Zugriff auf Hosts aus dem Ansible-Inventory. Diese Integration ermöglicht direkten SSH-Zugriff ohne manuelle Konfiguration.

Voraussetzungen

Die SSH-Integration funktioniert nur, wenn ein inventory.yml im Workspace vorhanden ist. Polycrate ermittelt automatisch: - SSH-Host-Adresse (ansible_host) - SSH-Port (ansible_ssh_port, default: 22) - SSH-User (ansible_user) - SSH-Schlüssel aus dem Workspace

Verfügbare Hosts anzeigen

Um alle verfügbaren Hosts im Workspace anzuzeigen:

polycrate ssh list

Ausgabe:

Available SSH hosts:
- web-1 (192.168.1.10)
- web-2 (192.168.1.11)
- db-1 (192.168.1.20)

SSH-Verbindung herstellen

Um eine SSH-Verbindung zu einem Host herzustellen:

polycrate ssh <hostname>

Beispiel:

polycrate ssh web-1

Polycrate: 1. Liest das Ansible-Inventory 2. Ermittelt automatisch die Verbindungsinformationen 3. Nutzt den SSH-Schlüssel aus dem Workspace (id_rsa) 4. Stellt die direkte SSH-Verbindung her

Beispiel-Workflow

1. Inventory erstellen

# inventory.yml im Workspace
all:
  hosts:
    web-1:
      ansible_host: 192.168.1.10
      ansible_user: ubuntu
      ansible_ssh_port: 22

    web-2:
      ansible_host: 192.168.1.11
      ansible_user: ubuntu

    db-1:
      ansible_host: 192.168.1.20
      ansible_user: postgres
      ansible_ssh_port: 2222

2. Verfügbare Hosts anzeigen

polycrate ssh list

3. Verbindung herstellen

polycrate ssh web-1

Verwendung

Direkter Zugriff für Debugging

# SSH zu Host
polycrate ssh web-1

# Befehl auf Host ausführen (interaktive Sitzung)
polycrate ssh web-1
# Dann im SSH-Terminal:
$ sudo systemctl status nginx
$ tail -f /var/log/application.log

Nach Ansible-Deployment

# 1. Server mit Ansible konfigurieren
polycrate run webservers configure

# 2. SSH für manuelle Checks
polycrate ssh web-1

# 3. Logs prüfen, Service neu starten, etc.

Hinweise

  • SSH-Schlüssel: Polycrate nutzt automatisch id_rsa aus dem Workspace-Root
  • Passphrase: Falls der SSH-Schlüssel eine Passphrase hat, werden Sie zur Eingabe aufgefordert ⚠️ Experimental
  • Port: Standard ist Port 22, kann aber per ansible_ssh_port im Inventory überschrieben werden
  • User: Wird aus ansible_user im Inventory gelesen

Schneller Zugriff

Mit polycrate ssh list und polycrate ssh <host> haben Sie schnellen Zugriff auf alle Server ohne SSH-Konfiguration manuell zu verwalten!