Meilenstein 3: Windows-Anbindung für itrdp:// und itssh://
- Gemeinsame, strenge Link-Prüfung in itconnect-common.ps1 (Regeln wie im Backend, Regex-Ende mit \z, nur Parameter host/port/user) - launch-rdp.ps1: mstsc /v bzw. temporäre .rdp-Datei bei Benutzername - launch-ssh.ps1: wt.exe ssh, Fallback auf ssh.exe - register-handlers.reg / unregister-handlers.reg (HKCU, Skripte unter Program Files) - test-launcher.ps1 mit gültigen und bösartigen Testlinks - .gitattributes: Windows-Dateien unverändert (CRLF, BOM) - SETUP.md: Installation, Test und Fehlerbilder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e89c4ad59
commit
37a60fc62a
8 files changed
+361
No files matched your search
@@ -0,0 +1,44 @@
|
||||
<#
|
||||
Öffnet eine SSH-Verbindung aus einem itssh://-Link in Windows Terminal (wt.exe).
|
||||
Ist Windows Terminal nicht installiert, wird ssh.exe direkt gestartet.
|
||||
Wird über den Protokoll-Handler aufgerufen (siehe register-handlers.reg):
|
||||
powershell.exe -File launch-ssh.ps1 "itssh://connect?host=...&port=...&user=..."
|
||||
Mit -Pruefen wird nur angezeigt, was gestartet würde (für Tests).
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true, Position = 0)][AllowEmptyString()][string]$Url,
|
||||
[switch]$Pruefen
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot 'itconnect-common.ps1')
|
||||
|
||||
function Get-ItcSshBefehl {
|
||||
param([Parameter(Mandatory = $true)]$Ziel, [bool]$MitTerminal = $true)
|
||||
# Alle Werte sind geprüft (keine Leerzeichen, Anführungszeichen oder ';'),
|
||||
# daher ist das Zusammensetzen der Argumente unkritisch.
|
||||
$sshArgs = @('-p', [string]$Ziel.Port)
|
||||
if ($null -ne $Ziel.User) { $sshArgs += @('-l', $Ziel.User) }
|
||||
$sshArgs += $Ziel.Host
|
||||
|
||||
if ($MitTerminal) {
|
||||
$argumente = @('new-tab', '--title', $Ziel.Host, 'ssh') + $sshArgs
|
||||
return [pscustomobject]@{ Programm = 'wt.exe'; Argumente = ($argumente -join ' ') }
|
||||
}
|
||||
return [pscustomobject]@{ Programm = 'ssh.exe'; Argumente = ($sshArgs -join ' ') }
|
||||
}
|
||||
|
||||
try {
|
||||
$ziel = ConvertFrom-ItcUrl -Url $Url -Schema 'itssh' -StandardPort 22
|
||||
$wt = Get-Command 'wt.exe' -ErrorAction SilentlyContinue
|
||||
$befehl = Get-ItcSshBefehl -Ziel $ziel -MitTerminal ($null -ne $wt)
|
||||
|
||||
if ($Pruefen) { return $befehl }
|
||||
|
||||
Start-Process -FilePath $befehl.Programm -ArgumentList $befehl.Argumente
|
||||
} catch {
|
||||
if ($Pruefen) { throw }
|
||||
Show-ItcFehler ('SSH-Verbindung konnte nicht geöffnet werden: ' + $_.Exception.Message)
|
||||
exit 1
|
||||
}
|
||||
Reference in new issue
Block a user