> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/server/de/knowledge-base/how-to-articles/install-devolutions-server-for-linux.md).

# Devolutions Server für Linux installieren

Devolutions Server ist für Linux mit Microsoft Kestrel als integriertem Webserver und Microsoft PowerShell 7 für die Installation über die Befehlszeile verfügbar. Das vorliegende Thema zeigt, wie Devolutions Server für Linux manuell mit Bash-Eingaben und PowerShell-Skripten installiert wird und wie darauf zugegriffen bzw. wie es entfernt wird.

Alternativ kann Devolutions Server automatisch mit den Skripten aus dem [Devolutions GitHub ScriptLibrary Repository](https://github.com/Devolutions/ScriptLibrary/tree/main/DVLSForLinux) installiert werden.

### Voraussetzungen installieren <a href="#installing-prerequisites" id="installing-prerequisites"></a>

1. Wenn Microsoft SQL Server noch nicht installiert ist, führen Sie die folgende Bash-Eingabe aus, wobei die Variable `MSSQL_SA_PASSWORD` auf ein starkes Passwort geändert wird:

   ```bash
   source /etc/os-release
   curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/microsoft-prod.gpg
   curl -fsSL https://packages.microsoft.com/config/ubuntu/$VERSION_ID/mssql-server-2022.list | sudo tee /etc/apt/sources.list.d/mssql-server-2022.list
   sudo apt-get update
   sudo apt-get install -y mssql-server
   sudo MSSQL_SA_PASSWORD="mystrongpassword" MSSQL_PID="evaluation" /opt/mssql/bin/mssql-conf -n setup accept-eula
   sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
   sudo systemctl restart mssql-server
   ```

   `MSSQL_PID` ist in diesem Beispiel auf ***evaluation*** gesetzt, hier kann jedoch stattdessen ein Produktschlüssel eingegeben werden.

{% hint style="warning" %}
Microsoft unterstützt nur [bestimmte SQL-Versionen](/server/de/readme/system-requirements.md#software-dependencies). Sehen Sie in der Dokumentation von Microsoft nach, um sicherzustellen, dass Ihre SQL-Version offiziell für Ihre Distribution unterstützt wird.
{% endhint %}

2. Führen Sie diese Bash-Eingabe aus, um PowerShell 7 zu installieren:

   ```bash
   sudo apt-get update
   sudo apt-get install -y wget apt-transport-https software-properties-common
   source /etc/os-release
   wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
   sudo dpkg -i packages-microsoft-prod.deb
   rm packages-microsoft-prod.deb
   sudo apt-get update
   sudo apt-get install -y powershell
   ```

Stellen Sie sicher, dass die Installation in einem Verzeichnis erfolgt, das für den aktuellen Benutzer zugänglich ist, da die Befehlszeile `wget` ein `.deb`-Paket in dieses Verzeichnis herunterlädt.

3. Wählen Sie, ob das [Devolutions.PowerShell-Modul](https://www.powershellgallery.com/packages/Devolutions.PowerShell/) für den aktuellen Benutzer oder für alle Benutzer installiert werden soll.

   * **Für den aktuellen Benutzer** (Speicherort: `/.local/share/powershell/Modules`) führen Sie aus:

     ```powershell
     Install-Module -Name 'Devolutions.PowerShell' -Confirm:$False
     ```
   * **Für alle Benutzer** (Speicherort: `/opt/microsoft/powershell/7/Modules`) führen Sie aus:

     ```powershell
     & sudo pwsh -Command { Install-Module -Name 'Devolutions.PowerShell' -Confirm:$False -Scope 'AllUsers' -Force }
     ```

   Wahrscheinlich erscheint eine Warnung, dass die Installation aus einem nicht vertrauenswürdigen Repository stammt. Das Modul wird in der PowerShell Gallery gehostet, dem offiziellen, von Microsoft verwalteten Speicherort für PowerShell-Module. Um diese Warnung künftig zu vermeiden, führen Sie aus:

   ```powershell
   Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
   ```

   Obwohl nicht erforderlich, wird die Bereitstellung separater Benutzer und Gruppen für Devolutions Server dringend empfohlen. Hier ist eine Bash-Eingabe, um einen Benutzer und eine Gruppe zu erstellen, die beide ***dvls*** heißen, wobei das Installationsverzeichnis auf `/opt/devolutions/dvls` gesetzt ist:

   ```bash
   sudo useradd -N dvls
   sudo groupadd dvls
   sudo usermod -a -G dvls dvls
   # optional, add current user to dvls group
   sudo usermod -a -G dvls $(id -un)
   sudo mkdir -p /opt/devolutions/dvls
   sudo chown -R dvls:dvls /opt/devolutions/dvls
   sudo chmod 550 /opt/devolutions/dvls
   ```

### Devolutions Server für Linux herunterladen und installieren <a href="#downloading-and-installing-dvls-for-linux" id="downloading-and-installing-dvls-for-linux"></a>

1. Führen Sie das nachstehende PowerShell-Skript aus, um die neueste Version von Devolutions Server für Linux herunterzuladen und die `.tar.gz`-Datei in den Speicherort `/opt/devolutions/dvls` zu extrahieren:

   ```powershell
   $DVLSPath = "/opt/devolutions/dvls"
   $DVLSProductURL = "https://devolutions.net/productinfo.htm"

   $Result = (Invoke-RestMethod -Method 'GET' -Uri $DVLSProductURL) -Split "`r"

   $DVLSLinux = [PSCustomObject]@{
       "Version" = (($Result | Select-String DPSLinuxX64bin.Version) -Split "=")[-1].Trim()
       "URL"     = (($Result | Select-String DPSLinuxX64bin.Url) -Split "=")[-1].Trim()
       "Hash"    = (($Result | Select-String DPSLinuxX64bin.hash) -Split "=")[-1].Trim()
   }

   $DVLSDownloadPath = Join-Path -Path "/tmp" -ChildPath (([URI]$DVLSLinux.URL).Segments)[-1]

   Invoke-RestMethod -Method 'GET' -Uri $DVLSLinux.URL -OutFile $DVLSDownloadPath

   & tar -xzf $DVLSDownloadPath -C $DVLSPath --strip-components=1

   Remove-Item -Path $DVLSDownloadPath

   & sudo pwsh -Command {
     Param(
         $DVLSPath
     )

     chown -R dvls:dvls $DVLSPath
     chmod -R o-rwx $DVLSPath
     chmod 660 (Join-Path -Path $DVLSPath -ChildPath 'appsettings.json')
     chmod 770 (Join-Path -Path $DVLSPath -ChildPath 'App_Data')
     chown -R dvls:dvls $DVLSPath
   } -Args $DVLSPath

   Set-Location -Path $DVLSPath
   ```

   Es ist am besten, wenn Devolutions Server über TLS antworten kann. Falls noch kein Zertifikat vorhanden ist, kann mit dieser Bash-Eingabe schnell eines generiert werden:

   ```bash
   cd /opt/devolutions/dvls

   openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout cert.key -out cert.crt -subj "/CN=MYHOST" -addext "subjectAltName=DNS:MYHOST"
   openssl pkcs12 -export -out cert.pfx -inkey cert.key -in cert.crt -passout pass:
   ```

   Im obigen Beispiel verwendet der `subjectAltName` `DNS:.` Um nur über eine IP zu antworten, verwenden Sie stattdessen `IP:`.

Beachten Sie, dass das generierte `.pfx`-Zertifikat kein Passwort hat.

2. Führen Sie mithilfe des Devolutions.PowerShell-Moduls die Installation von Devolutions Server über PowerShell aus. Passen Sie dabei unbedingt die hier aufgeführten Werte an:

   * `MYHOST`
   * `MSSQLHOST`
   * `DBUSERNAME`
   * `YOURSTRONGPASSWORD`
   * `MYEMAIL`

   ```powershell
   Import-Module -Name 'Devolutions.PowerShell'

   $DVLSPath = "/opt/devolutions/dvls"
   # Modify the $DVLSURI to use 'https' if using SSL
   $DVLSURI  = "http://MYHOST:5000/"

   $DVLSAdminUsername = 'dvls-admin'
   $DVLSAdminPassword = 'dvls-admin'
   $DVLSAdminEmail    = 'MYEMAIL'

   $Params = @{
       "DatabaseHost"           = "MSSQLHOST"
       "DatabaseName"           = "DSERVER"
       "DatabaseUserName"       = "DBUSERNAME"
       "DatabasePassword"       = "YOURSTRONGPASSWORD"
       "ServerName"             = "DSERVER"
       "AccessUri"              = $DVLSURI
       "HttpListenerUri"        = $DVLSURI
       "DPSPath"                = $DVLSPath
       "UseEncryptedconnection" = $False # Modify as needed
       "TrustServerCertificate" = $False # Modify as needed
       "EnableTelemetry"        = $True # Modify as needed
       "DisableEncryptConfig"   = $True
   }

   $Configuration = New-DPSInstallConfiguration @Params
   New-DPSAppsettings -Configuration $Configuration

   $Settings = Get-DPSAppSettings -ApplicationPath $DVLSPath

   New-DPSDatabase -ConnectionString $Settings.ConnectionStrings.LocalSqlServer
   Update-DPSDatabase -ConnectionString $Settings.ConnectionStrings.LocalSqlServer -InstallationPath $DVLSPath
   New-DPSDataSourceSettings -ConnectionString $Settings.ConnectionStrings.LocalSqlServer

   New-DPSEncryptConfiguration -ApplicationPath $DVLSPath
   New-DPSDatabaseAppSettings -Configuration $Configuration

   New-DPSAdministrator -ConnectionString $Settings.ConnectionStrings.LocalSqlServer -Name $DVLSAdminUsername -Password $DVLSAdminPassword -Email $DVLSAdminEmail
   ```

   Wenn bereits ein Zertifikat generiert wurde, ändern Sie die Datei `appsettings.json` mit diesem PowerShell-Skript, damit Kestrel über TLS antworten kann:

   ```powershell
   Import-Module -Name 'Devolutions.PowerShell'

   $DVLSPath = '/opt/devolutions/dvls'

   $JSON = Get-Content -Path (Join-Path -Path $DVLSPath -ChildPath 'appsettings.json') | ConvertFrom-JSON -Depth 100

   $JSON.Kestrel.Endpoints.Http | Add-Member -MemberType NoteProperty -Name 'Certificate' -Value @{
       'Path'     = (Join-Path -Path $DVLSPath -ChildPath 'cert.pfx')
       'Password' = ''
   }

   $JSON | ConvertTo-JSON -Depth 100 | Set-Content -Path (Join-Path -Path $DVLSPath -ChildPath 'appsettings.json')

   $Settings = Get-DPSAppSettings -ApplicationPath $DVLSPath

   $AccessUri = (Get-DPSAccessUri -ConnectionString $Settings.ConnectionStrings.LocalSqlServer).AccessUri
   Set-DPSAccessUri -ApplicationPath $DVLSPath -ConnectionString $Settings.ConnectionStrings.LocalSqlServer -AccessURI ($AccessUri -Replace "http","https")

   & sudo pwsh -Command {
     Param(
         $DVLSPath
     )

     & chown dvls:dvls (Join-Path -Path $DVLSPath -ChildPath 'cert.pfx')
   } -Args $DVLSPath
   ```

   Um den Hintergrundbetrieb von Devolutions Server für Linux zu ermöglichen, wird empfohlen, mit dieser Bash-Eingabe eine Unit-Datei für systemd zu erstellen:

   ```bash
   sudo tee /etc/systemd/system/dvls.service > /dev/null <<EOT
   [Unit]
   Description=DVLS

   [Service]
   Type=simple
   Restart=always
   RestartSec=10
   User=dvls
   ExecStart=/opt/devolutions/dvls/Devolutions.Server
   WorkingDirectory=/opt/devolutions/dvls
   KillSignal=SIGINT
   SyslogIdentifier=dvls
   Environment="SCHEDULER_EMBEDDED=true"

   [Install]
   WantedBy=multi-user.target
   Alias=dvls.service
   EOT

   sudo systemctl daemon-reload
   ```
3. Um Devolutions Server zu starten, führen Sie aus:

   ```bash
   sudo systemctl start dvls

   # View status
   sudo systemctl status dvls
   ```

### Auf Devolutions Server für Linux zugreifen <a href="#accessing-dvls-linux" id="accessing-dvls-linux"></a>

Standardmäßig lauscht Devolutions Server für Linux auf Port 5000 auf der IP oder dem Hostnamen des Installationssystems, was meist so aussieht: `http://MYHOST:5000`. Beachten Sie, dass beim ersten Start OAuth-Fehler auftreten können, wenn versucht wird, von einer nicht konfigurierten URL auf Devolutions Server zuzugreifen. Fügen Sie in diesem Fall weitere URIs hinzu, auf denen gelauscht wird, oder ändern Sie die primäre URI, indem Sie das folgende Skript in PowerShell ausführen:

```powershell
Import-Module -Name 'Devolutions.PowerShell'

$DVLSPath = "/opt/devolutions/dvls"

$Settings = Get-DPSAppSettings -ApplicationPath $DVLSPath
$ConnectionString = $Settings.ConnectionStrings.LocalSqlServer

Get-DPSAccessUri -ConnectionString $ConnectionString

Set-DPSAccessUri -ConnectionString $ConnectionString -ApplicationPath $DVLSPath -AccessURI 'http://10.10.0.20:5000/' -AdditionalAccessURIs @('http://ubuntu-2204:5000/')
```

Wenn Devolutions Server außerhalb des Installationssystems weiterhin nicht erreichbar ist, prüfen Sie, ob die erforderlichen Firewall-Ports geöffnet sind, indem Sie Uncomplicated Firewall zur Eingabe hinzufügen, zum Beispiel: `sudo ufw allow 5000`.

### Devolutions Server-Verschlüsselungsschlüssel importieren <a href="#importing-devolutions-server-encryption-key" id="importing-devolutions-server-encryption-key"></a>

**Export aus einer bestehenden Windows-Installation**

```powershell
Import-Module -Name 'Devolutions.PowerShell
$existingDVLSInstance = 'C:\my\path\dvlsInstance\'
$destination = 'C:\other\path\encryption.config'
Export-DPSEncryptionKeys -ApplicationPath $existingDVLSInstance -Destination $destination
```

**Import in eine neue Linux-Installation**

```powershell
Import-Module -Name 'Devolutions.PowerShell
$newDvlsInstance = '/home/user/linuxDlvsInstance'
$keysToImport = '/path/to/encryption.config'
Import-DPSEncryptionKeys -ApplicationPath $newDvlsInstance -Filename $keysToImport
```

### Devolutions Server für Linux aktualisieren <a href="#updating-devolutions-server-for-linux" id="updating-devolutions-server-for-linux"></a>

Extrahieren Sie das neue `.tar.gz`-Archiv nicht direkt über `/opt/devolutions/dvls.` Dadurch werden `appsettings.json` und `encryption.config` überschrieben, wodurch der Dienst nicht mehr starten kann und bestehende Daten möglicherweise nicht mehr entschlüsselt werden können. Befolgen Sie immer die auf dieser Seite beschriebene Aktualisierungsmethode.

1. Sichern Sie die Datenbank. So geht das für Microsoft SQL Server (Linux oder remote):

   ```
   /opt/mssql-tools18/bin/sqlcmd -S <MSSQLHOST> -U <DBUSERNAME> -P '<PASSWORD>' -C \
     -Q "BACKUP DATABASE [DSERVER] TO DISK = N'/var/opt/mssql/data/DSERVER-$(date +%F-%H%M).bak' WITH INIT, COMPRESSION;"
   ```

   Der vollständige Pfad zu `sqlcmd` vermeidet den Fehler **"**&#x63;ommand not found" in Non-Login-Shells, in denen `/etc/profile.d/mssql-tools.sh` nicht eingelesen wurde.

   `-C` vertraut dem Serverzertifikat (erforderlich für lokale SQL Server-Installationen, die ein selbstsigniertes Zertifikat verwenden).

   Sichern Sie in ein Verzeichnis, in das der MSSQL-Benutzer schreiben kann. `/var/opt/mssql/data/` funktioniert von Anfang an.
2. Stellen Sie sicher, dass die `.bak`-Datei vorhanden und nicht leer ist, bevor Sie mit dem nächsten Schritt fortfahren.
3. Stoppen Sie den Devolutions Server-Dienst mit dem folgenden Skript:

   ```bash
   sudo systemctl stop dvls.service
   sudo systemctl status dvls.service   # confirm inactive (dead)
   ```
4. Sichern Sie die Installations- und Konfigurationsdateien. Beachten Sie, dass `/opt/devolutions/dvls` im Modus 550 vorliegt und `dvls:dvls` gehört, weshalb die Backup-Cmdlets als root ausgeführt werden müssen. Starten Sie PowerShell mit `sudo pwsh` und fügen Sie dann dieses Skript ein:

   ```powershell
   Import-Module Devolutions.PowerShell
   $DVLSPath        = '/opt/devolutions/dvls'
   $BackupBase      = "/var/backups/dvls/$(Get-Date -Format 'yyyy-MM-dd-HHmm')"
   $BackupConfig    = Join-Path $BackupBase 'config'
   $BackupInstall   = Join-Path $BackupBase 'installation'
   mkdir -p $BackupConfig $BackupInstall
   Backup-DPSConfigurationFiles -ApplicationPath $DVLSPath -BackupConfigurationPath $BackupConfig
   Backup-DPSInstallationFiles  -ApplicationPath $DVLSPath -BackupPath              $BackupInstall
   ```

   * `Backup-DPSConfigurationFiles` sichert: `appsettings.json`, `web.config` und `encryption.config`.
   * `Backup-DPSInstallationFiles` sichert benutzerdefinierte Ordner, den Ordner für die Anomalieerkennung und alle von Benutzern hinzugefügten Assets.
5. Leeren Sie das Installationsverzeichnis mit Ausnahme von `App_data`, da dieses Laufzeitstatus enthält, der Upgrades übersteht. Verwenden Sie dazu dieses Skript:

   ```bash
   sudo find /opt/devolutions/dvls -mindepth 1 -maxdepth 1 ! -name 'App_Data' -exec rm -rf {} +
   sudo tar -xzf /tmp/DVLS.<version>.linux-x64.tar.gz -C /opt/devolutions/dvls --strip-components=1
   ```

   Verwenden Sie `--strip-components` nur, wenn das Archiv einen Ordner auf oberster Ebene hat.
6. Stellen Sie die Konfiguration und benutzerdefinierten Daten wieder her. In diesem Schritt werden `appsettings.json` (DB-Verbindungszeichenfolge) und `web.config` in die neue Installation zurückgelegt. Da `encryption.config` in Schritt #5 bereits innerhalb von `App_Data/` gesichert wurde, legt `Restore-DPSConfigurationFiles` sie nicht in das Installationsstammverzeichnis, weil sie sich unter Linux nicht dort befindet. Hier ist das Wiederherstellungsskript:

   ```
   Restore-DPSCustomFolders            -BackupPath              $BackupInstall -ApplicationPath $DVLSPath
   Restore-DPSAnomalyDetectionFolder   -BackupPath              $BackupInstall -ApplicationPath $DVLSPath
   Restore-DPSConfigurationFiles       -BackupConfigurationPath $BackupConfig  -ApplicationPath $DVLSPath
   ```
7. Rufen Sie die Verbindungszeichenfolgen aus der wiederhergestellten `appsettings.json` ab:

   ```
   $ConnectionString = (Get-DPSAppSettings -ApplicationPath $DVLSPath).ConnectionStrings.LocalSqlServer
   Update-DPSDatabase -ConnectionString $ConnectionString -InstallationPath $DVLSPath
   ```

   `Update-DPSDatabase` gibt bei Erfolg keine Ausgabe aus. Überprüfen Sie den Erfolg, indem Sie prüfen, ob der Befehl den Exit-Code 0 zurückgegeben hat und ob das Journal nach dem Starten des Dienstes in Schritt #9 Einträge mit ***Migration done with status Done*** ohne `[ERR]`-Zeilen anzeigt.
8. Wenden Sie Besitzrechte und Berechtigungen erneut an:

   ```
   sudo chown -R dvls:dvls /opt/devolutions/dvls
   sudo chmod 550 /opt/devolutions/dvls
   sudo chmod 660 /opt/devolutions/dvls/appsettings.json
   sudo chmod 770 /opt/devolutions/dvls/App_Data
   # If a certs/ directory is in use:
   [ -d /opt/devolutions/dvls/certs ] && sudo chmod 750 /opt/devolutions/dvls/certs
   ```
9. Starten Sie den Dienst und prüfen Sie, ob er korrekt funktioniert:

   ```
   sudo systemctl start dvls.service
   sudo systemctl status dvls.service
   sudo journalctl -u dvls.service -n 100 --no-pager
   ```

#### Fehlerbehebung <a href="#troubleshooting" id="troubleshooting"></a>

* **Dienst startet nicht, `appsettings.json` fehlt oder ist leer:** Stellen Sie sie aus `$BackupConfig/appsettings.json` wieder her und wiederholen Sie die Schritte #8 und 9.
* **Anmeldung funktioniert, aber Einträge können nicht entschlüsselt werden:** `encryption.config` wurde nicht wiederhergestellt. Kopieren Sie `$BackupConfig/encryption.config` nach `$DVLSPath/App_Data/`, korrigieren Sie die Berechtigungen (`chown dvls:dvls` und `chmod 660`) und starten Sie dann neu.
* **DB-Schemafehler zur Laufzeit:** `Update-DPSDatabase` wurde übersprungen oder ist fehlgeschlagen. Wiederholen Sie Schritt #7.
* **Vollständiges Rollback:** Stoppen Sie den Dienst (siehe Schritt #3), leeren Sie `/opt/devolutions/dvls` mit Ausnahme von `App_Data/` (Schritt #5), kopieren Sie den Inhalt von `$BackupInstall` zurück nach `/opt/devolutions/dvls`, stellen Sie `appsettings.json` aus `$BackupConfig` wieder her, wenden Sie Besitzrechte und Berechtigungen aus Schritt #8 erneut an, stellen Sie die DB aus der in Schritt #1 erstellten `.bak` wieder her und starten Sie dann neu.

### Devolutions Server entfernen <a href="#removing-dvls" id="removing-dvls"></a>

Um Devolutions Server zu entfernen, führen Sie die nachstehende Bash-Eingabe aus und passen Sie sie an das System an. Dieses Skript nutzt das [DbaTools PowerShell-Modul](https://dbatools.io/), um das Entfernen der MSSQL-Datenbank zu erleichtern. Es geht davon aus, dass `localhost` die MSSQL-Installation und `dvls` der Datenbankname ist.

```
# Remove DVLS on Linux, adjust as necessary
& sudo systemctl stop dvls.service
& sudo rm /etc/systemd/system/dvls.service
& sudo rm -rf /opt/devolutions/dvls
& sudo userdel -r dvls
& sudo groupdel dvls

Import-Module dbatools
$Credential = Get-Credential

Set-DbaToolsInsecureConnection

Remove-DbaDatabase -SqlInstance localhost -SqlCredential $Credential -Database 'dvls' -Confirm:$False
```


---

# 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://docs.devolutions.net/server/de/knowledge-base/how-to-articles/install-devolutions-server-for-linux.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.
