XXII. April 2022
Opnsense: Backup mit Rest-API (os-api-backup)
Für Opnsense kann man vieles über die Rest-API steuern. Um das Download der Config via Rest-API zu ermöglichen muss man das Plugin "os-api-backup" installieren.
Für den Benutzer root erstellt man einen neuen API-Key. Dabei erhält man man Key und Secret, diese trägt man in folgendes Powershellscript ein:
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
$key="rlvyQT7hQxDfCPe/JkZAozToIIeB4qSA0pYEjE9RIy6CxeJY5jTUGQtEUPyZC+5Uy32WCFh/5rtmh7nZ"
$secret="Eud10bBJTXhqDdLo4GfIWRMuSmiKEUTPoIp/JmHNlXpjzd2VA7RR1GLMUgEyKASIrWYDFBKm0zEtnEcO"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("$($key):$($secret)"))
$Header = @{
Authorization = "Basic $base64AuthInfo"
}
$Parameters = @{
Method = "GET"
Uri = "https://192.168.1.1/api/backup/backup/download"
Headers = $Header
}
$download = Invoke-RestMethod @Parameters
$download.Save("c:\opnsense\backup\download.xml")
Jetzt kann man mit via Powershell die Werte auslesen da der Rückgabewert ein XML ist. Z.b. seine ersten OpenVPN Settings:
$download.opnsense.openvpn.'openvpn-server'[0]
×
...auch noch interessant
- opnsense // 22.04.2022Opnsense: htop make (opnsense-code)
- opnsense // 22.04.2022Opnsense: Installation auf einen apu4d4 (GX-412TC pcengines)
- opnsense // 22.04.2022Linux USB to RS232 (UART)
- Powershell // 01.04.2022Powershell Where-Object mit Warp 7 beschleunigen
Tippsammlung
Kleine Tippsammlung für mich und dijenige die sich auf meine Webseite verirrt haben.Archiv
Jahr
Tag(s):- Jun 2024 (1)
- May 2024 (1)
- Apr 2024 (2)
- Feb 2024 (3)
- Jan 2024 (1)
- Sep 2023 (1)
- Jul 2023 (1)
- Apr 2023 (1)
- Feb 2023 (1)
- tipps (31)
- synology (27)
- linux (22)
- Windows (19)
- tool (19)
- Powershell (15)
- Windows 10 (13)
- csharp (c#) (10)
- coding (9)
- Ubuntu (6)
- security (6)
- ad (6)
- Windows 2012 R2 (5)
- vpn (5)
- Pi (5)
- gitea (5)
- git (5)
- Windows 2012 (4)
- Ubuntu 22.04 (4)
- opnsense (4)
- openpgp.js (4)
- mysql (4)
- docker (4)
- Xubuntu (3)
- Windows 2016 (3)
- web2 (3)
- seo (3)
- LMS (3)
- Japanisch (3)
- ipkg (3)
- bash (3)
- app (3)
- Android (3)
- Zertifizierungsstelle (2)
- www (2)
- wsus (2)
- Windows Updates (2)
- windows 2022 (2)
- Windows 2008 (2)
- wadoku (2)
- VMware (2)
- verschlüsselung (2)
- Scripts (2)
- php (2)
- pgp (2)
- perl (2)
- openvpn (2)
- Kanji (2)
- javascript (2)
- GnuPgP (2)
Nichts gefunden
Es wurde zur Story Opnsense: Backup mit Rest-API (os-api-backup) kein Kommentar gefundenInformation
Werbung oder Ähnliches sind nicht erlaubt, daher wird jeder Beitrag geprüft und freigegeben.Advertising, etc. are not allowed, so any contribution is reviewed and approved.
Facebook-Webadress are not allowed, Facebook als Webadresse ist nicht erlaubt
* Die E-Mail wird nicht veröffentlicht / The email will not be published
** Bitte Zahl eintragen / Please enter the number
Modal Header
Some text in the Modal Body
Some other text...
(c)2025 stastka.ch // help system