> For the complete documentation index, see [llms.txt](https://thorstenkramm.gitbook.io/saltstack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thorstenkramm.gitbook.io/saltstack/salt-ssh.md).

# Salt SSH

## Salt im Push Modus mit SSH

Salt-SSH benutzte nur SSH zum Verteilen und »ausführen« der Sates. Eine Installation der Minion-Software auf den Zielsystemen ist nicht notwendig.

### Salt-SSH installieren

Salt-SSH gehört nicht zum Standard-Umfang vom Salt-Master und muss mit `apt install salt-ssh` nachinstalliert werden.

### Inventar anlegen

`/etc/salt/roster`

{% code title="/etc/salt/roster" %}

```
web1:
  host: 192.168.42.1 # The IP addr or DNS hostname
  user: fred # Remote executions will be executed as user fred
  passwd: foobarbaz # The password to use for login, if omitted, keys are used
  sudo: True # Whether to sudo to root, not enabled by default
  priv: ~/.ssh/id_ed25519
web2:
  host: 192.168.42.2
```

{% endcode %}

{% hint style="info" %}
Sollte der Root-User des Salt-Masters noch kein SSH-Key-Paar haben, generieren Sie eines mit dem Kommando `ssh-keygen -N "" -t ed25519 -C "root@salt-master.local"` .
{% endhint %}

### Problem: Python fehlt

Auf einem minimal installieren System kann es passieren, dass Salt SSH auf der Gegenseite keine oder ein nicht ausreichend aktuelle Python Version installiert ist.

```
root@master:~# salt-ssh box1 test.ping
[ERROR   ] Failed collecting tops for Python binary python3.
[ERROR   ] ERROR: Failure deploying thin, retrying:
STDOUT:

STDERR:

RETCODE: 10
box1:
    ----------
    retcode:
        10
    stderr:
    stdout:
        ERROR: Python version error. Recommendation(s) follow:
        Install Python 2.6 / Python 3 Salt dependencies on the Salt SSH master 
        to interact with Python 2.6 / Python 3 targets
```

![Python fehlt :-(](/files/-LbEm-iBe57T5-DtYHg4)

#### Lösung

Über den sogenannten Raw-Modus, können Kommandos auch ohne Python ausgeführt werden, etwa die Installation von Python.&#x20;

```
# Debian/Ubuntu
salt-ssh <MINION-ID> -r 'sudo apt-get update; sudo apt-get -y install python3-minimal'
# Suse
salt-ssh <MINION-ID> -r "zypper --non-interactive install -y openssh-clients python3"
# RedHat
salt-ssh <MINION-ID> -r "yum -y install python3"
```

### Key automatisch akzeptieren

Wenn Sie viele Hosts per Salt SSH verwalten, möchten Sie nicht zu jedem Host eine manuelle SSH-Verbindung aufbauen, um den Fingerprint in der Know-Hosts-Datei zu speichern.\
Abhilfe schafft eine SSH-Client-Einstellung:

{% code title="/root/.ssh/config " %}

```
StrictHostKeyChecking no
```

{% endcode %}

### Defaults setzen

Anstatt für jeden Host in der Roster-Datei den Usernamen und den Port für die SSH-Verbindung zu setzen, können Sie auch den globalen Default ändern.

{% code title="/etc/salt/master.d/ssh.conf" %}

```yaml
ssh_sudo: False
ssh_timeout: 60
ssh_user: root
ssh_use_home_key: True
roster_defaults:
  priv: /root/.ssh/id_ed25519
```

{% endcode %}

Für alle weiteren SSH-Default-Werte siehe `grep ssh /etc/salt/master`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://thorstenkramm.gitbook.io/saltstack/salt-ssh.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
