Change SSH container to use SSH remoting
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
FROM alpine
|
||||
FROM ubuntu:16.04
|
||||
|
||||
RUN apk add --no-cache openssh-client
|
||||
RUN apt update \
|
||||
&& apt install -y wget openssh-client \
|
||||
&& wget -O powershell.deb https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-beta.6/powershell_6.0.0-beta.6-1ubuntu1.16.04.1_amd64.deb \
|
||||
&& dpkg -i powershell.deb; apt install -yf \
|
||||
&& rm -f powershell.deb
|
||||
|
||||
COPY ./windows /root/.ssh/id_rsa
|
||||
COPY ./ssh_config /root/.ssh/config
|
||||
COPY ./connect.ps1 /
|
||||
|
||||
CMD trap '' INT TSTP; while true; do ssh -t -L 2375:${WINDOWS_ENDPOINT}:2375 -q -o StrictHostKeyChecking=no Administrator@${WINDOWS_ENDPOINT} powershell; done
|
||||
|
||||
CMD powershell -NoExit -File /connect.ps1 -endpoint ${WINDOWS_ENDPOINT}
|
||||
|
||||
26
connect.ps1
Normal file
26
connect.ps1
Normal file
@@ -0,0 +1,26 @@
|
||||
Param(
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string]$endpoint
|
||||
)
|
||||
|
||||
function RegisterEvent {
|
||||
if ($event) {
|
||||
Unregister-Event $event
|
||||
}
|
||||
($global:event = Register-ObjectEvent -InputObject $session.Runspace -EventName AvailabilityChanged -Action {
|
||||
if ($session.State -eq "Broken") {
|
||||
$global:session = New-PSSession -HostName $endpoint -UserName Administrator
|
||||
RegisterEvent
|
||||
}
|
||||
if ($Host.Runspace -ne $session.Runspace) {
|
||||
Enter-PSSession $session
|
||||
}
|
||||
}) | Out-Null
|
||||
}
|
||||
|
||||
|
||||
$global:session = New-PSSession -HostName $endpoint -UserName Administrator
|
||||
Enter-PSSession $session
|
||||
RegisterEvent
|
||||
|
||||
|
||||
2
ssh_config
Normal file
2
ssh_config
Normal file
@@ -0,0 +1,2 @@
|
||||
Host *
|
||||
StrictHostKeyChecking no
|
||||
Reference in New Issue
Block a user