Skip to content

Instantly share code, notes, and snippets.

@ebekker
Created March 21, 2018 13:17
Show Gist options
  • Save ebekker/60afa998f1a540d38100cbfacb97ad33 to your computer and use it in GitHub Desktop.
Save ebekker/60afa998f1a540d38100cbfacb97ad33 to your computer and use it in GitHub Desktop.
Troubleshooting Win32-OpenSSH install via DSC cChoco
2018-03-21 03:34:35,590 1340 [DEBUG] - XmlConfiguration is now operational
2018-03-21 03:34:35,637 1340 [INFO ] - ============================================================
2018-03-21 03:34:35,793 1340 [INFO ] - Chocolatey v0.10.8
2018-03-21 03:34:35,824 1340 [DEBUG] - Chocolatey is running on Windows v 10.0.14393.0
2018-03-21 03:34:35,856 1340 [DEBUG] - Attempting to delete file "c:/ezsops/choco/choco.exe.old".
2018-03-21 03:34:35,856 1340 [DEBUG] - Attempting to delete file "c:\ezsops\choco\choco.exe.old".
2018-03-21 03:34:35,887 1340 [DEBUG] - Command line: "c:\ezsops\choco\choco.exe" install openssh -y "--params=/SSHServerFeature /SSHServerPort:22"
2018-03-21 03:34:35,902 1340 [DEBUG] - Received arguments: install openssh -y --params=/SSHServerFeature /SSHServerPort:22
2018-03-21 03:34:35,949 1340 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2018-03-21 03:34:35,965 1340 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2018-03-21 03:34:35,965 1340 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2018-03-21 03:34:36,012 1340 [DEBUG] - The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type
2018-03-21 03:34:36,012 1340 [DEBUG] -
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
output to a gist for review.
2018-03-21 03:34:36,027 1340 [DEBUG] - Configuration: CommandName='install'|CacheLocation='C:\Windows\TEMP\chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='False'|Verbose='False'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='False'|AcceptLicense='True'|
AllowUnofficialBuild='False'|Input='openssh'|AllVersions='False'|
SkipPackageInstallProvider='False'|PackageNames='openssh'|
Prerelease='False'|ForceX86='False'|OverrideArguments='False'|
NotSilent='False'|
PackageParameters='/SSHServerFeature /SSHServerPort:22'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='10.0.14393.0'|
Information.PlatformName='Windows Server 2016'|
Information.ChocolateyVersion='0.10.8.0'|
Information.ChocolateyProductVersion='0.10.8'|
Information.FullName='choco, Version=0.10.8.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|
Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='False'|
Information.UserName='SYSTEM'|Information.UserDomainName='sbox'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='True'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
PinCommand.Command='unknown'|OutdatedCommand.IgnorePinned='False'|
Proxy.BypassOnLocal='True'|
2018-03-21 03:34:36,027 1340 [DEBUG] - _ Chocolatey:ChocolateyInstallCommand - Normal Run Mode _
2018-03-21 03:34:36,043 1340 [INFO ] - Installing the following packages:
2018-03-21 03:34:36,043 1340 [INFO ] - openssh
2018-03-21 03:34:36,059 1340 [INFO ] - By installing you accept licenses for the packages.
2018-03-21 03:34:36,809 1340 [INFO ] - [NuGet] Installing 'openssh 7.6.0.1'.
2018-03-21 03:34:36,824 1340 [DEBUG] - [NuGet] Added file '7z.dll' to folder 'openssh\tools'.
2018-03-21 03:34:36,840 1340 [DEBUG] - [NuGet] Added file '7z.exe' to folder 'openssh\tools'.
2018-03-21 03:34:36,856 1340 [DEBUG] - [NuGet] Added file '7z.exe.ignore' to folder 'openssh\tools'.
2018-03-21 03:34:36,856 1340 [DEBUG] - [NuGet] Added file 'barebonesinstaller.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,887 1340 [DEBUG] - [NuGet] Added file 'chocolateyinstall.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,902 1340 [DEBUG] - [NuGet] Added file 'chocolateyuninstall.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,902 1340 [DEBUG] - [NuGet] Added file 'fileinuseutils.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,902 1340 [DEBUG] - [NuGet] Added file 'Get-NetStat.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,902 1340 [DEBUG] - [NuGet] Added file 'LICENSE.txt' to folder 'openssh\tools'.
2018-03-21 03:34:36,918 1340 [DEBUG] - [NuGet] Added file 'OpenSSH-Win32.zip' to folder 'openssh\tools'.
2018-03-21 03:34:36,934 1340 [DEBUG] - [NuGet] Added file 'OpenSSH-Win64.zip' to folder 'openssh\tools'.
2018-03-21 03:34:36,934 1340 [DEBUG] - [NuGet] Added file 'Set-SSHDefaultShell.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,934 1340 [DEBUG] - [NuGet] Added file 'SetSpecialPrivileges.ps1' to folder 'openssh\tools'.
2018-03-21 03:34:36,949 1340 [DEBUG] - [NuGet] Added file 'VERIFICATION.txt' to folder 'openssh\tools'.
2018-03-21 03:34:36,981 1340 [DEBUG] - [NuGet] Added file 'openssh.nuspec' to folder 'openssh'.
2018-03-21 03:34:36,996 1340 [DEBUG] - [NuGet] Added file 'openssh.nupkg' to folder 'openssh'.
2018-03-21 03:34:37,012 1340 [INFO ] - [NuGet] Successfully installed 'openssh 7.6.0.1'.
2018-03-21 03:34:37,012 1340 [INFO ] -
openssh v7.6.0.1 [Approved]
2018-03-21 03:34:37,027 1340 [INFO ] - openssh package files install completed. Performing other installation steps.
2018-03-21 03:34:37,074 1340 [DEBUG] - Setting installer args for openssh
2018-03-21 03:34:37,074 1340 [DEBUG] - Setting package parameters for openssh
2018-03-21 03:34:37,074 1340 [DEBUG] - Contents of 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1':
2018-03-21 03:34:37,090 1340 [DEBUG] -
<#
ATTENTION: This code is used extensively to run under PowerShell 2.0 to update
images from RTM / SP1 source for Windows 7 and Server 2008 R2. It is also
used under Powershell Core to add OpenSSH to Nano. Test all enhancements and
fixes under these two specialty cases (speciality for Chocolatey packagers who are
likely up to the latest version on everything PowerShell).
#>
$ErrorActionPreference = 'Stop'; # stop on all errors
$ProductName = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name 'ProductName').ProductName
$EditionId = (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name 'EditionID').EditionId
#This has to work for Win7 (no get-ciminstance) and Nano (no get-wmiobject) - each of which specially construct win32_operatingsystem.version to handle before and after Windows 10 version numbers (which are in different registry keys)
If ($psversiontable.psversion.major -lt 3)
{
$OSVersionString = (Get-WMIObject Win32_OperatingSystem).version
}
Else
{
$OSVersionString = (Get-CIMInstance Win32_OperatingSystem).version
}
Write-Output "Running on: $ProductName, ($EditionId)"
Write-Output "Windows Version: $OSVersionString"
$RunningOnNano = $False
If ($EditionId -ilike '*Nano*')
{$RunningOnNano = $True}
If (Test-Path variable:shimgen)
{$RunningUnderChocolatey = $True}
Else
{ Write-Output "Running Without Chocolatey"}
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$OSBits = ([System.IntPtr]::Size * 8) #Get-ProcessorBits
#On 64-bit, always favor 64-bit Program Files no matter what our execution is now (works back past XP / Server 2003)
If ($env:ProgramFiles.contains('x86'))
{
$PF = $env:ProgramFiles.replace(' (x86)','')
}
Else
{
$PF = $env:ProgramFiles
}
If (Test-Path "$env:windir\sysnative")
{ #We are running in a 32-bit process under 64-bit Windows
$sys32dir = "$env:windir\sysnative"
}
Else
{ #We are on a 32-bit OS, or 64-bit proc on 64-bit OS
$sys32dir = "$env:windir\system32"
}
$filename = "$toolsdir\OpenSSH-Win$($OSBits).zip"
#$TargetFolder = "$PF\OpenSSH"
#$TargetFolderOld = "$PF\OpenSSH-Win$($OSBits)"
$TargetFolder = "$PF\OpenSSH-Win$($OSBits)"
$ExtractFolder = "$env:temp\OpenSSHTemp"
$sshdpath = Join-Path $TargetFolder "sshd.exe"
$sshagentpath = Join-Path $TargetFolder "ssh-agent.exe"
$sshdir = Join-Path $env:ProgramData "\ssh"
$logsdir = Join-Path $sshdir "logs"
$packageArgs = @{
packageName = 'openssh'
unziplocation = "$ExtractFolder"
fileType = 'EXE_MSI_OR_MSU' #only one of these: exe, msi, msu
checksum = 'B12769AE28FCF045DCE6330575DC4D7F3D5A0BEB'
checksumType = 'SHA1'
checksum64 = '6DC776D62DF097F8751A81AB0DC36DF0FF4EF341'
checksumType64= 'SHA1'
}
If ($RunningUnderChocolatey)
{
# Default the values before reading params
$SSHServerFeature = $false
$KeyBasedAuthenticationFeature = $false
$DeleteServerKeysAfterInstalled = $false
$UseNTRights = $false
$SSHServerPort = '22'
$DisableKeyPermissionsReset = $False
$arguments = @{};
$packageParameters = $env:chocolateyPackageParameters
}
$OpeningMessage = @"
************************************************************************************
************************************************************************************
This package is a Universal Installer and can ALSO install Win32-OpenSSH on
Nano, Server Core, Docker Containers and more WITHOUT using Chocolatey.
See the following for more details:
https://github.com/DarwinJS/ChocoPackages/blob/master/openssh/readme.md
************************************************************************************
************************************************************************************
"@
Write-Output $OpeningMessage
function Get-PackageParametersCustom {
[CmdletBinding()]
param(
[string] $Parameters = $Env:ChocolateyPackageParameters,
# Allows splatting with arguments that do not apply and future expansion. Do not use directly.
[parameter(ValueFromRemainingArguments = $true)]
[Object[]] $IgnoredArguments
)
$res = @{}
$re = "\/([a-zA-Z0-9]+)(:[`"'].+?[`"']|[^ ]+)?"
$results = $Parameters | Select-String $re -AllMatches | select -Expand Matches
foreach ($m in $results) {
if (!$m) { continue } # must because of posh 2.0 bug: https://github.com/chocolatey/chocolatey-coreteampackages/issues/465
$a = $m.Value -split ':'
$opt = $a[0].Substring(1); $val = $a[1..100] -join ':'
if ($val -match '^(".+")|(''.+'')$') {$val = $val -replace '^.|.$'}
$res[ $opt ] = if ($val) { $val } else { $true }
}
$res
}
# Now parse the packageParameters using good old regular expression
if ($packageparameters) {
$pp = Get-PackageParametersCustom
if ($pp.SSHAgentFeature) {
Write-Host "/SSHAgentFeature was used, including SSH Agent Service."
$SSHAgentFeature = $true
}
if ($pp.SSHServerFeature) {
Write-Host "/SSHServerFeature was used, including SSH Server Feature."
$SSHServerFeature = $true
}
if ($pp.DisableKeyPermissionsReset) {
Write-Host "/DisableKeyPermissionsReset was used, will not reset key permissions."
$DisableKeyPermissionsReset = $true
}
if ($pp.OverWriteSSHDConf) {
Write-Host "/OverWriteSSHDConf was used, will overwrite any existing sshd_conf with one from install media."
$OverWriteSSHDConf = $true
}
if ($pp.SSHServerPort) {
$SSHServerPort = $pp.Get_Item("SSHServerPort")
Write-Host "/SSHServerPort was used, attempting to use SSHD listening port $SSHServerPort."
If (!$SSHServerFeature)
{
Write-Host "You forgot to specify /SSHServerFeature with /SSHServerPort, autofixing for you, enabling /SSHServerFeature"
$SSHServerFeature = $true
}
}
if ($pp.SSHLogLevel) {
$ValidLogSettings = @('QUIET', 'FATAL', 'ERROR', 'INFO', 'VERBOSE', 'DEBUG', 'DEBUG1', 'DEBUG2','DEBUG3')
$SSHLogLevel = $pp.Get_Item("SSHLogLevel").toupper()
If ($ValidLogSettings -inotcontains $SSHLogLevel)
{Throw "$SSHLogLevel is not one of the valid values: $(($ValidLogSettings -join ' ') | out-string)"}
Write-Host "/SSHLogLevel was used, setting LogLevel in sshd_conf to $SSHLogLevel"
}
Else
{
$SSHLogLevel = $null
}
if ($pp.TERM) {
$TERM = $pp.Get_Item("TERM")
Write-Host "/TERM was used, setting system TERM environment variable to $TERM"
$TERMSwitchUsed = $True
}
if ($pp.UseNTRights) {
Write-Host "Using ntrights.exe to set service permissions (will not work, but generate warning if WOW64 is not present on 64-bit machines)"
$UseNTRights = $true
}
if ($pp.DeleteServerKeysAfterInstalled) {
Write-Host "Deleting server private keys after they have been secured."
$DeleteServerKeysAfterInstalled = $true
}
if ($pp.KeyBasedAuthenticationFeature) {
Write-Host "Including Key based authentication."
$KeyBasedAuthenticationFeature = $true
If (!$SSHServerFeature)
{
Write-Warning "KeyBasedAuthenticationFeature was specified, but is only value when SSHServerFeature is specified, ignoring..."
}
}
if ($pp.PathSpecsToProbeForShellEXEString) {
$PathSpecsToProbeForShellEXEString = $pp.Get_Item("PathSpecsToProbeForShellEXEString")
Write-Host "PathSpecsToProbeForShellEXEString was used, probing for suitable shell using search specs: $PathSpecsToProbeForShellEXEString"
}
if ($pp.AllowInsecureShellEXE) {
$AllowInsecureShellEXE = $True
}
if ($pp.SSHDefaultShellCommandOption) {
$SSHDefaultShellCommandOption = $pp.Get_Item("SSHDefaultShellCommandOption")
}
} else {
Write-Debug "No Package Parameters Passed in";
}
Function CheckServicePath ($ServiceEXE,$FolderToCheck)
{
if ($RunningOnNano) {
#The NANO TP5 Compatible Way:
Return ([bool](@(wmic service | ?{$_ -ilike "*$ServiceEXE*"}) -ilike "*$FolderToCheck*"))
}
Else
{
#The modern way:
Return ([bool]((Get-WmiObject win32_service | ?{$_.PathName -ilike "*$ServiceEXE*"} | select -expand PathName) -ilike "*$FolderToCheck*"))
}
}
#Extract Files Early
If ($RunningUnderChocolatey)
{
If (Test-Path $ExtractFolder)
{
Remove-Item $ExtractFolder -Recurse -Force
}
Get-ChocolateyUnzip "$filename" $ExtractFolder
}
Else
{
If (Test-Path "$toolsdir\7z.exe")
{
#covers nano
cd $toolsdir
start-process .\7z.exe -argumentlist "x `"$filename`" -o`"$ExtractFolder`" -aoa" -nonewwindow -wait
}
Else
{
Throw "You need a copy of 7z.exe next to this script for this operating system. You can get a copy at 7-zip.org"
}
}
If ($SSHServerFeature -OR $SSHAgentFeature)
{
. "$toolsdir\SetSpecialPrivileges.ps1"
}
If ($SSHServerFeature)
{ #Check if anything is already listening on port $SSHServerPort, which is not a previous version of this software.
$AtLeastOneSSHDPortListenerIsNotUs = $False
Write-Output "Probing for possible conflicts with SSHD server to be configured on port $SSHServerPort ..."
. "$toolsdir\Get-NetStat.ps1"
$procslisteningonRequestedSSHDPort = @(Get-Netstat -GetProcessDetails -FilterOnPort $SSHServerPort)
If ((checkservicepath 'svchost.exe -k SshBrokerGroup' 'Part of Microsoft SSH Server for Windows') -AND (checkservicepath 'svchost.exe -k SshProxyGroup' 'Part of Microsoft SSH Server for Windows'))
{
Write-Warning " > Detected that Developer Mode SSH is present (Probably due to enabling Windows 10 Developer Mode)"
$DeveloperModeSSHIsPresent = $True
}
If ($procslisteningonRequestedSSHDPort.count -ge 1)
{
ForEach ($proconRequestedSSHDPort in $procslisteningonRequestedSSHDPort)
{
Write-output " > Checking $($proconRequestedSSHDPort.Localaddressprocesspath) against path $TargetFolder"
If ("$($proconRequestedSSHDPort.Localaddressprocesspath)" -ilike "*$TargetFolder*")
{
Write-Output " > Found a previous version of Win32-OpenSSH installed by this package on Port $SSHServerPort."
}
Else
{
$AtLeastOneSSHDPortListenerIsNotUs = $True
Write-Warning " > Found something listening on Port $SSHServerPort that was not installed by this package."
Write-Warning " $($proconRequestedSSHDPort.LocalAddressProcessPath) is listening on Port $SSHServerPort"
$ProcessOccupyingPort = "$($proconRequestedSSHDPort.LocalAddressProcessPath)"
}
}
}
If ($AtLeastOneSSHDPortListenerIsNotUs)
{
$errorMessagePort = @"
"$ProcessOccupyingPort" is listening on port $SSHServerPort and you have not specified a different listening port (list above) using the /SSHServerPort parameter.
Please either deconfigure or deinstall whatever is running on Port $SSHServerPort and try again OR specify a different port for this SSHD Server using the /SSHServerPort package parameter.
If you see the message 'Detected that Developer Mode SSH is present' above, you may be able to simply disable the services 'SSHBroker' and 'SSHProxy'
"@
Throw $errorMessagePort
}
}
$SSHServiceInstanceExistsAndIsOurs = CheckServicePath 'sshd.exe' "$TargetFolder"
$SSHAGENTServiceInstanceExistsAndIsOurs = CheckServicePath 'ssh-agent.exe' "$TargetFolder"
If ($SSHServerFeature -AND (!$SSHServiceInstanceExistsAndIsOurs) -AND ([bool](Get-Service sshd -ErrorAction SilentlyContinue)))
{
$ExistingSSHDInstancePath = get-itemproperty hklm:\system\currentcontrolset\services\* | where {($_.ImagePath -ilike '*sshd.exe*')} | Select -expand ImagePath
Throw "You have requested that the SSHD service be installed, but this system appears to have an instance of an SSHD service configured for another folder ($ExistingSSHDInstancePath). You can remove the package switch /SSHServerFeature to install just the client tools, or you will need to remove that instance of SSHD to use the one that comes with this package."
}
If ((!$SSHServerFeature) -AND $SSHServiceInstanceExistsAndIsOurs)
{
Throw "There is a configured instance of the SSHD service, please specify the /SSHServerFeature to confirm it is OK to shutdown and upgrade the SSHD service at this time."
}
If ([bool](get-process ssh -erroraction silentlycontinue | where {$_.Path -ilike "*$TargetFolder*"}))
{
Throw "It appears you have instances of ssh.exe (client) running from the folder this package installs to, please terminate them and try again."
}
If ((Test-Path $TargetFolder) -AND (@(dir "$TargetFolder\*.exe").count -gt 0))
{
Write-Output "`r`nCURRENT VERSIONS OF SSH EXES:"
Write-Output "$(dir "$TargetFolder\*.exe"| select -expand fullname | get-command | select -expand fileversioninfo | ft filename, fileversion -auto | out-string)"
}
If (Test-Path "$env:windir\system32\ssh-lsa.dll")
{
Write-Output "`r`nCURRENT VERSION OF SSH-LSA.DLL:"
Write-Output "$(get-command "$env:windir\system32\ssh-lsa.dll" | select -expand fileversioninfo | ft filename, fileversion -auto | out-string)"
}
If ($SSHServiceInstanceExistsAndIsOurs -AND ([bool](Get-Service SSHD -ErrorAction SilentlyContinue | where {$_.Status -ieq 'Running'})))
{
#Shutdown and unregister service for upgrade
stop-service sshd -Force
Start-Sleep -seconds 3
If (([bool](Get-Service SSHD | where {$_.Status -ieq 'Running'})))
{
Throw "Could not stop the SSHD service, please stop manually and retry this package."
}
If ($SSHAGENTServiceInstanceExistsAndIsOurs)
{
Stop-Service SSH-Agent -Force
Start-Sleep -seconds 3
If (([bool](Get-Service ssh-agent | where {$_.Status -ieq 'Running'})))
{
Throw "Could not stop the ssh-agent service, please stop manually and retry this package."
}
}
}
If ($SSHServiceInstanceExistsAndIsOurs)
{
Write-output "Stopping SSHD Service for upgrade..."
Stop-Service sshd
sc.exe delete sshd | out-null
}
If ($SSHAGENTServiceInstanceExistsAndIsOurs)
{
Write-output "Stopping SSH-Agent Service for upgrade..."
Stop-Service ssh-agent -erroraction silentlycontinue
sc.exe delete ssh-agent | out-null
}
If ($OSBits -eq 64)
{
$SourceZipChecksum = $packageargs.checksum64
$SourceZipChecksumType = $packageargs.checksumType64
}
Else
{
$SourceZipChecksum = $packageargs.checksum
$SourceZipChecksumType = $packageargs.checksumType
}
If ([bool](get-command get-filehash -ea silentlycontinue))
{
If ((Get-FileHash $filename -Algorithm $SourceZipChecksumType).Hash -eq $SourceZipChecksum)
{
Write-Output "Hashes for internal source match"
}
Else
{
throw "Checksums for internal source do not match - something is wrong."
}
}
Else
{
Write-Output "Source files are internal to the package, checksums are not required nor checked."
}
Copy-Item "$ExtractFolder\*" "$PF" -Force -Recurse -Passthru -ErrorAction Stop
#Fixed version of module
#Write-Host "Updating OpenSSHUtils PowerShell Module to Latest"
#Copy-Item "$toolsdir\OpenSSHUtils.ps*" "$TargetFolder" -Force -PassThru -ErrorAction Stop
Copy-Item "$toolsdir\Set-SSHDefaultShell.ps1" "$TargetFolder" -Force -PassThru -ErrorAction Stop
Remove-Item "$ExtractFolder" -Force -Recurse
If ($RunningUnderChocolatey)
{
Install-ChocolateyPath "$TargetFolder" 'Machine'
}
Else
{
$PathToAdd = $TargetFolder
$ExistingPathArray = @(((Get-ItemProperty 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' | select -expand path).split(';')))
if (($ExistingPathArray -inotcontains $PathToAdd) -AND ($ExistingPathArray -inotcontains "$PathToAdd\"))
{
$Newpath = $ExistingPathArray + @("$PathToAdd")
$AssembledNewPath = ($newpath -join(';')).trimend(';')
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name 'PATH' -Value "$AssembledNewPath"
}
}
If ($env:Path -inotlike "*$TargetFolder*")
{
$env:path += ";$TargetFolder"
}
$ExistingTermValue = $null
$ExistingTermValue = (get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -EA SilentlyContinue | Select -Expand TERM -EA SilentlyContinue)
If ((!$ExistingTermValue) -OR ($ExistingTermValue -ine $TERM))
{
Write-Host "Updating machine environment variable TERM from `"$ExistingTermValue`" to `"$TERM`""
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name 'TERM' -Value "$TERM"
}
If ($SSHAgentFeature)
{
New-Service -Name ssh-agent -BinaryPathName "$TargetFolder\ssh-agent.exe" -Description "SSH Agent" -StartupType Automatic | Out-Null
cmd.exe /c 'sc.exe sdset ssh-agent D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)(A;;RP;;;AU)'
Start-Service ssh-agent
Start-Sleep -seconds 3
#The code in this .PS1 has been tested on Nano - the hardest case to date for setting special privileges in script
#$sshagentSid = (Get-OpenSSHUserSID -User "NT SERVICE\SSH-Agent").Value
#Add-OpenSSHPrivilege -Account $sshagentSid -Privilege SeServiceLogonRight
}
If ($SSHServerFeature)
{
Write-Warning "You have specified SSHServerFeature - this machine is being configured as an SSH Server including opening port $SSHServerPort."
#create the ssh config folder and set its permissions
if(-not (test-path $sshdir -PathType Container))
{
$null = New-Item $sshdir -ItemType Directory -Force -ErrorAction Stop
}
$acl = Get-Acl -Path $sshdir
# following SDDL implies
# - owner - built in Administrators
# - disabled inheritance
# - Full access to System
# - Full access to built in Administrators
$acl.SetSecurityDescriptorSddlForm("O:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;OICI;0x1200a9;;;AU)")
Set-Acl -Path $sshdir -AclObject $acl
# create logs folder and set its permissions
if(-not (test-path $logsdir -PathType Container))
{
$null = New-Item $logsdir -ItemType Directory -Force -ErrorAction Stop
}
$acl = Get-Acl -Path $logsdir
# following SDDL implies
# - owner - built in Administrators
# - disabled inheritance
# - Full access to System
# - Full access to built in Administrators
$acl.SetSecurityDescriptorSddlForm("O:BAD:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)")
Set-Acl -Path $logsdir -AclObject $acl
If((Test-Path "$TargetFolder\sshd_config"))
{
Write-Host "Migrating existing sshd_config to new location `"$sshdir`""
Move-Item "$TargetFolder\sshd_config" $sshdir -force
}
#for clean config copy sshd_config_default to $sshdir\sshd_config
$sshdconfigpath = Join-Path $sshdir "sshd_config"
$sshddefaultconfigpath = Join-Path $TargetFolder "sshd_config_default"
if(-not (test-path $sshdconfigpath -PathType Leaf))
{
$null = Copy-Item $sshddefaultconfigpath -Destination $sshdconfigpath -ErrorAction Stop
}
If((Test-Path "$TargetFolder\ssh_host_*"))
{
Write-Host "Migrating existing ssh host keys to new location `"$sshdir`""
Move-Item "$TargetFolder\ssh_host_*" $sshdir -force
}
If((Test-Path "$sshdconfigpath"))
{
$CurrentLogLevelConfig = ((gc "$sshdconfigpath") -imatch "^#*LogLevel\s\w*\b.*$")
Write-Output 'Setting up SSH Logging'
If ($SSHLogLevel)
{ #command line specified a log level - override whatever is there
If ([bool]($CurrentLogLevelConfig -inotmatch "^LogLevel\s$SSHLogLevel\s*$"))
{
Write-Output "Current LogLevel setting in `"$sshdconfigpath`" is `"$CurrentLogLevelConfig`", setting it to `"LogLevel $SSHLogLevel`""
(Get-Content "$sshdconfigpath") -replace "^#*LogLevel\s\w*\b.*$", "LogLevel $SSHLogLevel" | Set-Content "$sshdconfigpath"
}
}
Else
{ #command line did not specify a log level, set it to QUIET - only if it has never been set (currently commented INFO setting)
If((Test-Path "$sshdconfigpath") -AND ([bool]((gc "$sshdconfigpath") -ilike "#LogLevel INFO*")))
{
Write-Warning "Explicitly disabling sshd logging as it currently logs about .5 GB / hour"
(Get-Content "$sshdconfigpath") -replace '#LogLevel INFO', 'LogLevel QUIET' | Set-Content "$sshdconfigpath"
}
}
$CurrentPortConfig = ((gc "$sshdconfigpath") -match "^#*Port\s\d*\s*$")
If ([bool]($CurrentPortConfig -notmatch "^Port $SSHServerPort"))
{
Write-Output "Current port setting in `"$sshdconfigpath`" is `"$CurrentPortConfig`", setting it to `"Port $SSHServerPort`""
(Get-Content "$sshdconfigpath") -replace "^#*Port\s\d*\s*$", "Port $SSHServerPort" | Set-Content "$sshdconfigpath"
}
Else
{
Write-Output "Current port setting in `"$sshdconfigpath`" already matches `"Port $SSHServerPort`", no action necessary."
}
}
If ($PathSpecsToProbeForShellEXEString)
{
$ParamsSSHDefaultShell = @{}
$ParamsSSHDefaultShell.add('PathSpecsToProbeForShellEXEString',"$PathSpecsToProbeForShellEXEString")
If ($AllowInsecureShellEXE) {$ParamsSSHDefaultShell += @{'AllowInsecureShellEXE'=$AllowInsecureShellEXE}
If ($SSHDefaultShellCommandOption) {$ParamsSSHDefaultShell += @{'SSHDefaultShellCommandOption'="$SSHDefaultShellCommandOption"}
Write-Host "$ParamsSSHDefaultShell"
. $TargetFolder\Set-SSHDefaultShell.ps1 @ParamsSSHDefaultShell
}
netsh advfirewall firewall add rule name='SSHD Port OpenSSH (chocolatey package: openssh)' dir=in action=allow protocol=TCP localport=$SSHServerPort
$keylist = "ssh_host_dsa_key", "ssh_host_rsa_key", "ssh_host_ecdsa_key", "ssh_host_ed25519_key"
If ($DeleteServerKeysAfterInstalled)
{
pushd $TargetFolder
Foreach ($keyfile in $keylist)
{
If (Test-Path $keyfile)
{
Remove-Item $keyfile -force
}
}
popd
}
Else
{
Write-Warning "The following private keys should be removed from the machine: $keylist"
}
New-Service -Name sshd -BinaryPathName "$TargetFolder\sshd.exe" -Description "SSH Daemon" -StartupType Automatic | Out-Null
#sc.exe config sshd obj= "NT SERVICE\SSHD"
#sc.exe privs sshd SeAssignPrimaryTokenPrivilege
#The code in this .PS1 has been tested on Nano - the hardest case to date for setting special privileges in script
#$sshdSid = (Get-OpenSSHUserSID -User "NT SERVICE\SSHD").value
#Add-OpenSSHPrivilege -Account $sshdSid -Privilege SeAssignPrimaryTokenPrivilege
#Add-OpenSSHPrivilege -Account $sshdSid -Privilege SeServiceLogonRight
Write-Host "Ensuring all ssh key and configuration files have correct permissions for all users"
. "$TargetFolder\FixHostFilePermissions.ps1" -Confirm:$false
}
If (CheckServicePath 'sshd.exe' "$TargetFolder")
{
write-output "Starting SSHD..."
Start-Service SSHD
}
If (CheckServicePath 'ssh-agent.exe' "$TargetFolder")
{
write-output "Starting SSH-Agent..."
Start-Service SSH-Agent
}
$fullpathkeylist = "'$sshdir\ssh_host_dsa_key'", "'$sshdir\ssh_host_rsa_key'", "'$sshdir\ssh_host_ecdsa_key'", "'$sshdir\ssh_host_ed25519_key'"
If ($SSHServerFeature)
{
If (!(Test-Path "$sshdir\KeysAddedToAgent.flg"))
{
Write-Output "Installing Server Keys into SSH-Agent"
schtasks.exe /create /RU "NT AUTHORITY\SYSTEM" /RL HIGHEST /SC ONSTART /TN "ssh-add" /TR "'$TargetFolder\ssh-add.exe' $fullpathkeylist" /F
schtasks.exe /Run /I /TN "ssh-add"
schtasks.exe /Delete /TN "ssh-add" /F
New-Item "$sshdir\KeysAddedToAgent.flg" -type File | out-null
}
}
If (Test-Path "$TargetFolder\ssh.exe")
{
Write-Output "`r`nNEW VERSIONS OF SSH EXES:"
Write-Output "$(dir "$TargetFolder\*.exe" | select -expand fullname | get-command | select -expand fileversioninfo | ft filename, fileversion -auto | out-string)"
}
write-output ""
Write-Warning "You must start a new prompt, or use the command 'refreshenv' (provided by your chocolatey install) to re-read the environment for the tools to be available in this shell session."
2018-03-21 03:34:37,152 1340 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'c:\ezsops\choco\helpers\chocolateyInstaller.psm1'; & 'c:\ezsops\choco\helpers\chocolateyScriptRunner.ps1' -packageScript 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1' -installArguments '' -packageParameters '/SSHServerFeature /SSHServerPort:22'']
2018-03-21 03:34:37,215 1340 [DEBUG] - Redirecting System.Management.Automation.resources, Version=3.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35, requested by ''
2018-03-21 03:34:37,465 1340 [DEBUG] - Host version is 5.1.14393.0, PowerShell Version is '5.1.14393.2097' and CLR Version is '4.0.30319.42000'.
2018-03-21 03:34:37,829 1340 [INFO ] - VERBOSE: Exporting function 'Format-FileSize'.
2018-03-21 03:34:37,891 1340 [INFO ] - VERBOSE: Exporting function 'Get-ChecksumValid'.
2018-03-21 03:34:37,954 1340 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
2018-03-21 03:34:38,032 1340 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
2018-03-21 03:34:38,126 1340 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariable'.
2018-03-21 03:34:38,204 1340 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
2018-03-21 03:34:38,282 1340 [INFO ] - VERBOSE: Exporting function 'Get-FtpFile'.
2018-03-21 03:34:38,360 1340 [INFO ] - VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
2018-03-21 03:34:38,454 1340 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
2018-03-21 03:34:38,532 1340 [INFO ] - VERBOSE: Exporting function 'Get-ToolsLocation'.
2018-03-21 03:34:38,610 1340 [INFO ] - VERBOSE: Exporting function 'Get-UACEnabled'.
2018-03-21 03:34:38,704 1340 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
2018-03-21 03:34:38,782 1340 [INFO ] - VERBOSE: Exporting function 'Get-VirusCheckValid'.
2018-03-21 03:34:38,876 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebFile'.
2018-03-21 03:34:38,954 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebFileName'.
2018-03-21 03:34:39,032 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebHeaders'.
2018-03-21 03:34:39,126 1340 [INFO ] - VERBOSE: Exporting function 'Install-BinFile'.
2018-03-21 03:34:39,204 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
2018-03-21 03:34:39,282 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
2018-03-21 03:34:39,376 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
2018-03-21 03:34:39,454 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
2018-03-21 03:34:39,516 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
2018-03-21 03:34:39,563 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPackage'.
2018-03-21 03:34:39,626 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPath'.
2018-03-21 03:34:39,626 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
2018-03-21 03:34:39,642 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
2018-03-21 03:34:39,642 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
2018-03-21 03:34:39,659 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
2018-03-21 03:34:39,659 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
2018-03-21 03:34:39,674 1340 [INFO ] - VERBOSE: Exporting function 'Install-Vsix'.
2018-03-21 03:34:39,674 1340 [INFO ] - VERBOSE: Exporting function 'Set-EnvironmentVariable'.
2018-03-21 03:34:39,690 1340 [INFO ] - VERBOSE: Exporting function 'Set-PowerShellExitCode'.
2018-03-21 03:34:39,690 1340 [INFO ] - VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
2018-03-21 03:34:39,705 1340 [INFO ] - VERBOSE: Exporting function 'Test-ProcessAdminRights'.
2018-03-21 03:34:39,705 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-BinFile'.
2018-03-21 03:34:39,721 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
2018-03-21 03:34:39,721 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
2018-03-21 03:34:39,737 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
2018-03-21 03:34:39,737 1340 [INFO ] - VERBOSE: Exporting function 'Update-SessionEnvironment'.
2018-03-21 03:34:39,752 1340 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateyFailure'.
2018-03-21 03:34:39,752 1340 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateySuccess'.
2018-03-21 03:34:39,768 1340 [INFO ] - VERBOSE: Exporting function 'Write-FileUpdateLog'.
2018-03-21 03:34:39,768 1340 [INFO ] - VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
2018-03-21 03:34:39,784 1340 [INFO ] - VERBOSE: Exporting alias 'Get-ProcessorBits'.
2018-03-21 03:34:39,784 1340 [INFO ] - VERBOSE: Exporting alias 'Get-OSBitness'.
2018-03-21 03:34:39,799 1340 [INFO ] - VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
2018-03-21 03:34:39,815 1340 [INFO ] - VERBOSE: Exporting alias 'Generate-BinFile'.
2018-03-21 03:34:39,815 1340 [INFO ] - VERBOSE: Exporting alias 'Add-BinFile'.
2018-03-21 03:34:39,830 1340 [INFO ] - VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
2018-03-21 03:34:39,830 1340 [INFO ] - VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
2018-03-21 03:34:39,846 1340 [INFO ] - VERBOSE: Exporting alias 'Remove-BinFile'.
2018-03-21 03:34:39,846 1340 [INFO ] - VERBOSE: Exporting alias 'refreshenv'.
2018-03-21 03:34:39,862 1340 [DEBUG] - Loading community extensions
2018-03-21 03:34:39,877 1340 [DEBUG] - Importing 'C:\ezsops\choco\extensions\chocolatey-core\chocolatey-core.psm1'
2018-03-21 03:34:39,877 1340 [INFO ] - VERBOSE: Loading module from path 'C:\ezsops\choco\extensions\chocolatey-core\chocolatey-core.psm1'.
2018-03-21 03:34:39,940 1340 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
2018-03-21 03:34:39,955 1340 [INFO ] - VERBOSE: Exporting function 'Get-AppInstallLocation'.
2018-03-21 03:34:39,955 1340 [INFO ] - VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
2018-03-21 03:34:39,971 1340 [INFO ] - VERBOSE: Exporting function 'Get-EffectiveProxy'.
2018-03-21 03:34:39,971 1340 [INFO ] - VERBOSE: Exporting function 'Get-PackageCacheLocation'.
2018-03-21 03:34:39,987 1340 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
2018-03-21 03:34:39,987 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebContent'.
2018-03-21 03:34:40,002 1340 [INFO ] - VERBOSE: Exporting function 'Register-Application'.
2018-03-21 03:34:40,002 1340 [INFO ] - VERBOSE: Importing function 'Get-AppInstallLocation'.
2018-03-21 03:34:40,018 1340 [INFO ] - VERBOSE: Importing function 'Get-AvailableDriveLetter'.
2018-03-21 03:34:40,018 1340 [INFO ] - VERBOSE: Importing function 'Get-EffectiveProxy'.
2018-03-21 03:34:40,034 1340 [INFO ] - VERBOSE: Importing function 'Get-PackageCacheLocation'.
2018-03-21 03:34:40,034 1340 [INFO ] - VERBOSE: Importing function 'Get-PackageParameters'.
2018-03-21 03:34:40,049 1340 [INFO ] - VERBOSE: Importing function 'Get-UninstallRegistryKey'.
2018-03-21 03:34:40,049 1340 [INFO ] - VERBOSE: Importing function 'Get-WebContent'.
2018-03-21 03:34:40,065 1340 [INFO ] - VERBOSE: Importing function 'Register-Application'.
2018-03-21 03:34:40,080 1340 [DEBUG] - Importing 'C:\ezsops\choco\extensions\chocolatey-windowsupdate\chocolatey-windowsupdate.psm1'
2018-03-21 03:34:40,080 1340 [INFO ] - VERBOSE: Loading module from path 'C:\ezsops\choco\extensions\chocolatey-windowsupdate\chocolatey-windowsupdate.psm1'.
2018-03-21 03:34:40,127 1340 [INFO ] - VERBOSE: Exporting function 'Install-WindowsUpdate'.
2018-03-21 03:34:40,143 1340 [INFO ] - VERBOSE: Exporting function 'Test-WindowsUpdate'.
2018-03-21 03:34:40,143 1340 [INFO ] - VERBOSE: Importing function 'Install-WindowsUpdate'.
2018-03-21 03:34:40,159 1340 [INFO ] - VERBOSE: Importing function 'Test-WindowsUpdate'.
2018-03-21 03:34:40,159 1340 [INFO ] - VERBOSE: Exporting function 'Format-FileSize'.
2018-03-21 03:34:40,174 1340 [INFO ] - VERBOSE: Exporting function 'Get-ChecksumValid'.
2018-03-21 03:34:40,174 1340 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyUnzip'.
2018-03-21 03:34:40,190 1340 [INFO ] - VERBOSE: Exporting function 'Get-ChocolateyWebFile'.
2018-03-21 03:34:40,190 1340 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariable'.
2018-03-21 03:34:40,205 1340 [INFO ] - VERBOSE: Exporting function 'Get-EnvironmentVariableNames'.
2018-03-21 03:34:40,205 1340 [INFO ] - VERBOSE: Exporting function 'Get-FtpFile'.
2018-03-21 03:34:40,221 1340 [INFO ] - VERBOSE: Exporting function 'Get-OSArchitectureWidth'.
2018-03-21 03:34:40,221 1340 [INFO ] - VERBOSE: Exporting function 'Get-PackageParameters'.
2018-03-21 03:34:40,237 1340 [INFO ] - VERBOSE: Exporting function 'Get-ToolsLocation'.
2018-03-21 03:34:40,237 1340 [INFO ] - VERBOSE: Exporting function 'Get-UACEnabled'.
2018-03-21 03:34:40,252 1340 [INFO ] - VERBOSE: Exporting function 'Get-UninstallRegistryKey'.
2018-03-21 03:34:40,252 1340 [INFO ] - VERBOSE: Exporting function 'Get-VirusCheckValid'.
2018-03-21 03:34:40,268 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebFile'.
2018-03-21 03:34:40,268 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebFileName'.
2018-03-21 03:34:40,284 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebHeaders'.
2018-03-21 03:34:40,284 1340 [INFO ] - VERBOSE: Exporting function 'Install-BinFile'.
2018-03-21 03:34:40,299 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyDesktopLink'.
2018-03-21 03:34:40,315 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyEnvironmentVariable'.
2018-03-21 03:34:40,315 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyExplorerMenuItem'.
2018-03-21 03:34:40,330 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyFileAssociation'.
2018-03-21 03:34:40,330 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyInstallPackage'.
2018-03-21 03:34:40,346 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPackage'.
2018-03-21 03:34:40,346 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPath'.
2018-03-21 03:34:40,362 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPinnedTaskBarItem'.
2018-03-21 03:34:40,362 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyPowershellCommand'.
2018-03-21 03:34:40,377 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyShortcut'.
2018-03-21 03:34:40,377 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyVsixPackage'.
2018-03-21 03:34:40,393 1340 [INFO ] - VERBOSE: Exporting function 'Install-ChocolateyZipPackage'.
2018-03-21 03:34:40,393 1340 [INFO ] - VERBOSE: Exporting function 'Install-Vsix'.
2018-03-21 03:34:40,409 1340 [INFO ] - VERBOSE: Exporting function 'Set-EnvironmentVariable'.
2018-03-21 03:34:40,409 1340 [INFO ] - VERBOSE: Exporting function 'Set-PowerShellExitCode'.
2018-03-21 03:34:40,424 1340 [INFO ] - VERBOSE: Exporting function 'Start-ChocolateyProcessAsAdmin'.
2018-03-21 03:34:40,424 1340 [INFO ] - VERBOSE: Exporting function 'Test-ProcessAdminRights'.
2018-03-21 03:34:40,440 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-BinFile'.
2018-03-21 03:34:40,440 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyEnvironmentVariable'.
2018-03-21 03:34:40,455 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyPackage'.
2018-03-21 03:34:40,455 1340 [INFO ] - VERBOSE: Exporting function 'Uninstall-ChocolateyZipPackage'.
2018-03-21 03:34:40,471 1340 [INFO ] - VERBOSE: Exporting function 'Update-SessionEnvironment'.
2018-03-21 03:34:40,487 1340 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateyFailure'.
2018-03-21 03:34:40,487 1340 [INFO ] - VERBOSE: Exporting function 'Write-ChocolateySuccess'.
2018-03-21 03:34:40,502 1340 [INFO ] - VERBOSE: Exporting function 'Write-FileUpdateLog'.
2018-03-21 03:34:40,502 1340 [INFO ] - VERBOSE: Exporting function 'Write-FunctionCallLogMessage'.
2018-03-21 03:34:40,518 1340 [INFO ] - VERBOSE: Exporting function 'Get-AppInstallLocation'.
2018-03-21 03:34:40,518 1340 [INFO ] - VERBOSE: Exporting function 'Get-AvailableDriveLetter'.
2018-03-21 03:34:40,534 1340 [INFO ] - VERBOSE: Exporting function 'Get-EffectiveProxy'.
2018-03-21 03:34:40,534 1340 [INFO ] - VERBOSE: Exporting function 'Get-PackageCacheLocation'.
2018-03-21 03:34:40,549 1340 [INFO ] - VERBOSE: Exporting function 'Get-WebContent'.
2018-03-21 03:34:40,549 1340 [INFO ] - VERBOSE: Exporting function 'Register-Application'.
2018-03-21 03:34:40,565 1340 [INFO ] - VERBOSE: Exporting function 'Install-WindowsUpdate'.
2018-03-21 03:34:40,565 1340 [INFO ] - VERBOSE: Exporting function 'Test-WindowsUpdate'.
2018-03-21 03:34:40,580 1340 [INFO ] - VERBOSE: Exporting alias 'Get-ProcessorBits'.
2018-03-21 03:34:40,580 1340 [INFO ] - VERBOSE: Exporting alias 'Get-OSBitness'.
2018-03-21 03:34:40,596 1340 [INFO ] - VERBOSE: Exporting alias 'Get-InstallRegistryKey'.
2018-03-21 03:34:40,612 1340 [INFO ] - VERBOSE: Exporting alias 'Generate-BinFile'.
2018-03-21 03:34:40,612 1340 [INFO ] - VERBOSE: Exporting alias 'Add-BinFile'.
2018-03-21 03:34:40,627 1340 [INFO ] - VERBOSE: Exporting alias 'Start-ChocolateyProcess'.
2018-03-21 03:34:40,627 1340 [INFO ] - VERBOSE: Exporting alias 'Invoke-ChocolateyProcess'.
2018-03-21 03:34:40,643 1340 [INFO ] - VERBOSE: Exporting alias 'Remove-BinFile'.
2018-03-21 03:34:40,643 1340 [INFO ] - VERBOSE: Exporting alias 'refreshenv'.
2018-03-21 03:34:40,659 1340 [INFO ] - VERBOSE: Importing function 'Format-FileSize'.
2018-03-21 03:34:40,659 1340 [INFO ] - VERBOSE: Importing function 'Get-AppInstallLocation'.
2018-03-21 03:34:40,674 1340 [INFO ] - VERBOSE: Importing function 'Get-AvailableDriveLetter'.
2018-03-21 03:34:40,674 1340 [INFO ] - VERBOSE: Importing function 'Get-ChecksumValid'.
2018-03-21 03:34:40,690 1340 [INFO ] - VERBOSE: Importing function 'Get-ChocolateyUnzip'.
2018-03-21 03:34:40,690 1340 [INFO ] - VERBOSE: Importing function 'Get-ChocolateyWebFile'.
2018-03-21 03:34:40,705 1340 [INFO ] - VERBOSE: Importing function 'Get-EffectiveProxy'.
2018-03-21 03:34:40,705 1340 [INFO ] - VERBOSE: Importing function 'Get-EnvironmentVariable'.
2018-03-21 03:34:40,721 1340 [INFO ] - VERBOSE: Importing function 'Get-EnvironmentVariableNames'.
2018-03-21 03:34:40,721 1340 [INFO ] - VERBOSE: Importing function 'Get-FtpFile'.
2018-03-21 03:34:40,737 1340 [INFO ] - VERBOSE: Importing function 'Get-OSArchitectureWidth'.
2018-03-21 03:34:40,737 1340 [INFO ] - VERBOSE: Importing function 'Get-PackageCacheLocation'.
2018-03-21 03:34:40,752 1340 [INFO ] - VERBOSE: Importing function 'Get-PackageParameters'.
2018-03-21 03:34:40,752 1340 [INFO ] - VERBOSE: Importing function 'Get-ToolsLocation'.
2018-03-21 03:34:40,768 1340 [INFO ] - VERBOSE: Importing function 'Get-UACEnabled'.
2018-03-21 03:34:40,768 1340 [INFO ] - VERBOSE: Importing function 'Get-UninstallRegistryKey'.
2018-03-21 03:34:40,784 1340 [INFO ] - VERBOSE: Importing function 'Get-VirusCheckValid'.
2018-03-21 03:34:40,784 1340 [INFO ] - VERBOSE: Importing function 'Get-WebContent'.
2018-03-21 03:34:40,799 1340 [INFO ] - VERBOSE: Importing function 'Get-WebFile'.
2018-03-21 03:34:40,799 1340 [INFO ] - VERBOSE: Importing function 'Get-WebFileName'.
2018-03-21 03:34:40,815 1340 [INFO ] - VERBOSE: Importing function 'Get-WebHeaders'.
2018-03-21 03:34:40,815 1340 [INFO ] - VERBOSE: Importing function 'Install-BinFile'.
2018-03-21 03:34:40,830 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyDesktopLink'.
2018-03-21 03:34:40,830 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyEnvironmentVariable'.
2018-03-21 03:34:40,846 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyExplorerMenuItem'.
2018-03-21 03:34:40,846 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyFileAssociation'.
2018-03-21 03:34:40,862 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyInstallPackage'.
2018-03-21 03:34:40,862 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPackage'.
2018-03-21 03:34:40,877 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPath'.
2018-03-21 03:34:40,877 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPinnedTaskBarItem'.
2018-03-21 03:34:40,893 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyPowershellCommand'.
2018-03-21 03:34:40,893 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyShortcut'.
2018-03-21 03:34:40,909 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyVsixPackage'.
2018-03-21 03:34:40,909 1340 [INFO ] - VERBOSE: Importing function 'Install-ChocolateyZipPackage'.
2018-03-21 03:34:40,924 1340 [INFO ] - VERBOSE: Importing function 'Install-Vsix'.
2018-03-21 03:34:40,924 1340 [INFO ] - VERBOSE: Importing function 'Install-WindowsUpdate'.
2018-03-21 03:34:40,940 1340 [INFO ] - VERBOSE: Importing function 'Register-Application'.
2018-03-21 03:34:40,955 1340 [INFO ] - VERBOSE: Importing function 'Set-EnvironmentVariable'.
2018-03-21 03:34:40,955 1340 [INFO ] - VERBOSE: Importing function 'Set-PowerShellExitCode'.
2018-03-21 03:34:40,971 1340 [INFO ] - VERBOSE: Importing function 'Start-ChocolateyProcessAsAdmin'.
2018-03-21 03:34:40,971 1340 [INFO ] - VERBOSE: Importing function 'Test-ProcessAdminRights'.
2018-03-21 03:34:40,987 1340 [INFO ] - VERBOSE: Importing function 'Test-WindowsUpdate'.
2018-03-21 03:34:40,987 1340 [INFO ] - VERBOSE: Importing function 'Uninstall-BinFile'.
2018-03-21 03:34:41,002 1340 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyEnvironmentVariable'.
2018-03-21 03:34:41,002 1340 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyPackage'.
2018-03-21 03:34:41,018 1340 [INFO ] - VERBOSE: Importing function 'Uninstall-ChocolateyZipPackage'.
2018-03-21 03:34:41,018 1340 [INFO ] - VERBOSE: Importing function 'Update-SessionEnvironment'.
2018-03-21 03:34:41,034 1340 [INFO ] - VERBOSE: Importing function 'Write-ChocolateyFailure'.
2018-03-21 03:34:41,034 1340 [INFO ] - VERBOSE: Importing function 'Write-ChocolateySuccess'.
2018-03-21 03:34:41,049 1340 [INFO ] - VERBOSE: Importing function 'Write-FileUpdateLog'.
2018-03-21 03:34:41,049 1340 [INFO ] - VERBOSE: Importing function 'Write-FunctionCallLogMessage'.
2018-03-21 03:34:41,065 1340 [INFO ] - VERBOSE: Importing alias 'Add-BinFile'.
2018-03-21 03:34:41,065 1340 [INFO ] - VERBOSE: Importing alias 'Generate-BinFile'.
2018-03-21 03:34:41,080 1340 [INFO ] - VERBOSE: Importing alias 'Get-InstallRegistryKey'.
2018-03-21 03:34:41,096 1340 [INFO ] - VERBOSE: Importing alias 'Get-OSBitness'.
2018-03-21 03:34:41,096 1340 [INFO ] - VERBOSE: Importing alias 'Get-ProcessorBits'.
2018-03-21 03:34:41,112 1340 [INFO ] - VERBOSE: Importing alias 'Invoke-ChocolateyProcess'.
2018-03-21 03:34:41,112 1340 [INFO ] - VERBOSE: Importing alias 'refreshenv'.
2018-03-21 03:34:41,127 1340 [INFO ] - VERBOSE: Importing alias 'Remove-BinFile'.
2018-03-21 03:34:41,127 1340 [INFO ] - VERBOSE: Importing alias 'Start-ChocolateyProcess'.
2018-03-21 03:34:41,159 1340 [DEBUG] - Running 'ChocolateyScriptRunner' for openssh v7.6.0.1 with packageScript 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1', packageFolder:'c:\ezsops\choco\lib\openssh', installArguments: '', packageParameters: '/SSHServerFeature /SSHServerPort:22',
2018-03-21 03:34:41,174 1340 [DEBUG] - Running 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1'
2018-03-21 03:34:41,346 1340 [INFO ] - VERBOSE: Perform operation 'Enumerate CimInstances' with following parameters, ''namespaceName' = root\cimv2,'className' = Win32_OperatingSystem'.
2018-03-21 03:34:41,393 1340 [INFO ] - VERBOSE: Operation 'Enumerate CimInstances' complete.
2018-03-21 03:34:41,393 1340 [INFO ] - Running on: Windows Server 2016 Datacenter, (ServerDatacenter)
2018-03-21 03:34:41,409 1340 [INFO ] - Windows Version: 10.0.14393
2018-03-21 03:34:41,424 1340 [INFO ] -
************************************************************************************
************************************************************************************
This package is a Universal Installer and can ALSO install Win32-OpenSSH on
Nano, Server Core, Docker Containers and more WITHOUT using Chocolatey.
See the following for more details:
https://github.com/DarwinJS/ChocoPackages/blob/master/openssh/readme.md
************************************************************************************
************************************************************************************
2018-03-21 03:34:41,455 1340 [INFO ] - /SSHServerFeature was used, including SSH Server Feature.
2018-03-21 03:34:41,471 1340 [INFO ] - /SSHServerPort was used, attempting to use SSHD listening port 22.
2018-03-21 03:34:41,534 1340 [DEBUG] - Running Get-ChocolateyUnzip -fileFullPath 'C:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip' -destination 'C:\Windows\TEMP\chocolatey\OpenSSHTemp'
2018-03-21 03:34:41,534 1340 [DEBUG] - Running Get-ProcessorBits -compare '32'
2018-03-21 03:34:41,549 1340 [INFO ] - Extracting C:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip to C:\Windows\TEMP\chocolatey\OpenSSHTemp...
2018-03-21 03:34:41,565 1340 [DEBUG] - 7zip found at 'C:\ezsops\choco\tools\7z.exe'
2018-03-21 03:34:41,565 1340 [DEBUG] - Executing command ['C:\ezsops\choco\tools\7z.exe' x -aoa -bd -bb1 -o"C:\Windows\TEMP\chocolatey\OpenSSHTemp" -y "C:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip"]
2018-03-21 03:34:42,176 1340 [INFO ] - VERBOSE:
2018-03-21 03:34:42,176 1340 [INFO ] - VERBOSE: 7-Zip [32] 16.04 : Copyright (c) 1999-2016 Igor Pavlov : 2016-10-04
2018-03-21 03:34:42,191 1340 [INFO ] - VERBOSE:
2018-03-21 03:34:42,191 1340 [INFO ] - VERBOSE: Scanning the drive for archives:
2018-03-21 03:34:42,207 1340 [INFO ] - VERBOSE: 1 file, 3377860 bytes (3299 KiB)
2018-03-21 03:34:42,207 1340 [INFO ] - VERBOSE:
2018-03-21 03:34:42,222 1340 [INFO ] - VERBOSE: Extracting archive: C:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip
2018-03-21 03:34:42,222 1340 [INFO ] - VERBOSE: --
2018-03-21 03:34:42,238 1340 [INFO ] - VERBOSE: Path = C:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip
2018-03-21 03:34:42,238 1340 [INFO ] - VERBOSE: Type = zip
2018-03-21 03:34:42,254 1340 [INFO ] - VERBOSE: Physical Size = 3377860
2018-03-21 03:34:42,254 1340 [INFO ] - VERBOSE:
2018-03-21 03:34:42,269 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\FixHostFilePermissions.ps1
2018-03-21 03:34:42,269 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\FixUserFilePermissions.ps1
2018-03-21 03:34:42,285 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\install-sshd.ps1
2018-03-21 03:34:42,285 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\libcrypto.dll
2018-03-21 03:34:42,301 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\OpenSSHUtils.psd1
2018-03-21 03:34:42,301 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\OpenSSHUtils.psm1
2018-03-21 03:34:42,301 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\scp.exe
2018-03-21 03:34:42,316 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\sftp.exe
2018-03-21 03:34:42,316 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\sftp-server.exe
2018-03-21 03:34:42,332 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\ssh.exe
2018-03-21 03:34:42,332 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\ssh-add.exe
2018-03-21 03:34:42,347 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\ssh-agent.exe
2018-03-21 03:34:42,347 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\sshd.exe
2018-03-21 03:34:42,347 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\sshd_config_default
2018-03-21 03:34:42,363 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\ssh-keygen.exe
2018-03-21 03:34:42,363 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\ssh-keyscan.exe
2018-03-21 03:34:42,379 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\ssh-shellhost.exe
2018-03-21 03:34:42,379 1340 [INFO ] - VERBOSE: - OpenSSH-Win64\uninstall-sshd.ps1
2018-03-21 03:34:42,394 1340 [INFO ] - VERBOSE: Everything is Ok
2018-03-21 03:34:42,394 1340 [INFO ] - VERBOSE:
2018-03-21 03:34:42,394 1340 [INFO ] - VERBOSE: Files: 18
2018-03-21 03:34:42,410 1340 [INFO ] - VERBOSE: Size: 7390211
2018-03-21 03:34:42,426 1340 [INFO ] - VERBOSE: Compressed: 3377860
2018-03-21 03:34:42,472 1340 [DEBUG] - $exitCode was passed null
2018-03-21 03:34:42,472 1340 [DEBUG] - Command ['C:\ezsops\choco\tools\7z.exe' x -aoa -bd -bb1 -o"C:\Windows\TEMP\chocolatey\OpenSSHTemp" -y "C:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip"] exited with '0'.
2018-03-21 03:34:42,472 1340 [DEBUG] - 7z exit code: 0
2018-03-21 03:34:42,488 1340 [INFO ] - C:\Windows\TEMP\chocolatey\OpenSSHTemp
2018-03-21 03:34:42,519 1340 [DEBUG] -
using System;
namespace MyLsaWrapper
{
using System.Runtime.InteropServices;
using System.Security;
using System.ComponentModel;
using System.Security.Principal;
using LSA_HANDLE = IntPtr;
[StructLayout(LayoutKind.Sequential)]
struct LSA_OBJECT_ATTRIBUTES
{
internal int Length;
internal IntPtr RootDirectory;
internal IntPtr ObjectName;
internal int Attributes;
internal IntPtr SecurityDescriptor;
internal IntPtr SecurityQualityOfService;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
struct LSA_UNICODE_STRING
{
internal ushort Length;
internal ushort MaximumLength;
[MarshalAs(UnmanagedType.LPWStr)]
internal string Buffer;
}
sealed class Win32Sec
{
[DllImport("advapi32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaOpenPolicy(
LSA_UNICODE_STRING[] SystemName,
ref LSA_OBJECT_ATTRIBUTES ObjectAttributes,
int AccessMask,
out IntPtr PolicyHandle
);
[DllImport("advapi32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaAddAccountRights(
LSA_HANDLE PolicyHandle,
IntPtr pSID,
LSA_UNICODE_STRING[] UserRights,
int CountOfRights
);
[DllImport("advapi32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaRemoveAccountRights(
LSA_HANDLE PolicyHandle,
IntPtr pSID,
bool AllRights,
LSA_UNICODE_STRING[] UserRights,
int CountOfRights
);
[DllImport("advapi32")]
internal static extern int LsaNtStatusToWinError(int NTSTATUS);
[DllImport("advapi32")]
internal static extern int LsaClose(IntPtr PolicyHandle);
}
internal sealed class Sid : IDisposable
{
public IntPtr pSid = IntPtr.Zero;
public System.Security.Principal.SecurityIdentifier sid = null;
public Sid(string account)
{
try { sid = new SecurityIdentifier(account); }
catch { sid = (SecurityIdentifier)(new NTAccount(account)).Translate(typeof(SecurityIdentifier)); }
Byte[] buffer = new Byte[sid.BinaryLength];
sid.GetBinaryForm(buffer, 0);
pSid = Marshal.AllocHGlobal(sid.BinaryLength);
Marshal.Copy(buffer, 0, pSid, sid.BinaryLength);
}
public void Dispose()
{
if (pSid != IntPtr.Zero)
{
Marshal.FreeHGlobal(pSid);
pSid = IntPtr.Zero;
}
GC.SuppressFinalize(this);
}
~Sid() { Dispose(); }
}
public sealed class LsaWrapper : IDisposable
{
enum Access : int
{
POLICY_READ = 0x20006,
POLICY_ALL_ACCESS = 0x00F0FFF,
POLICY_EXECUTE = 0X20801,
POLICY_WRITE = 0X207F8
}
const uint STATUS_ACCESS_DENIED = 0xc0000022;
const uint STATUS_INSUFFICIENT_RESOURCES = 0xc000009a;
const uint STATUS_NO_MEMORY = 0xc0000017;
const uint STATUS_OBJECT_NAME_NOT_FOUND = 0xc0000034;
const uint STATUS_NO_MORE_ENTRIES = 0x8000001a;
IntPtr lsaHandle;
public LsaWrapper() : this(null) { } // local system if systemName is null
public LsaWrapper(string systemName)
{
LSA_OBJECT_ATTRIBUTES lsaAttr;
lsaAttr.RootDirectory = IntPtr.Zero;
lsaAttr.ObjectName = IntPtr.Zero;
lsaAttr.Attributes = 0;
lsaAttr.SecurityDescriptor = IntPtr.Zero;
lsaAttr.SecurityQualityOfService = IntPtr.Zero;
lsaAttr.Length = Marshal.SizeOf(typeof(LSA_OBJECT_ATTRIBUTES));
lsaHandle = IntPtr.Zero;
LSA_UNICODE_STRING[] system = null;
if (systemName != null)
{
system = new LSA_UNICODE_STRING[1];
system[0] = InitLsaString(systemName);
}
uint ret = Win32Sec.LsaOpenPolicy(system, ref lsaAttr, (int)Access.POLICY_ALL_ACCESS, out lsaHandle);
if (ret == 0) return;
if (ret == STATUS_ACCESS_DENIED) throw new UnauthorizedAccessException();
if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY)) throw new OutOfMemoryException();
throw new Win32Exception(Win32Sec.LsaNtStatusToWinError((int)ret));
}
public void AddPrivilege(string account, string privilege)
{
uint ret = 0;
using (Sid sid = new Sid(account))
{
LSA_UNICODE_STRING[] privileges = new LSA_UNICODE_STRING[1];
privileges[0] = InitLsaString(privilege);
ret = Win32Sec.LsaAddAccountRights(lsaHandle, sid.pSid, privileges, 1);
}
if (ret == 0) return;
if (ret == STATUS_ACCESS_DENIED) throw new UnauthorizedAccessException();
if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY)) throw new OutOfMemoryException();
throw new Win32Exception(Win32Sec.LsaNtStatusToWinError((int)ret));
}
public void RemovePrivilege(string account, string privilege)
{
uint ret = 0;
using (Sid sid = new Sid(account))
{
LSA_UNICODE_STRING[] privileges = new LSA_UNICODE_STRING[1];
privileges[0] = InitLsaString(privilege);
ret = Win32Sec.LsaRemoveAccountRights(lsaHandle, sid.pSid, false, privileges, 1);
}
if (ret == 0) return;
if (ret == STATUS_ACCESS_DENIED) throw new UnauthorizedAccessException();
if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY)) throw new OutOfMemoryException();
throw new Win32Exception(Win32Sec.LsaNtStatusToWinError((int)ret));
}
public void Dispose()
{
if (lsaHandle != IntPtr.Zero)
{
Win32Sec.LsaClose(lsaHandle);
lsaHandle = IntPtr.Zero;
}
GC.SuppressFinalize(this);
}
~LsaWrapper() { Dispose(); }
// helper functions:
static LSA_UNICODE_STRING InitLsaString(string s)
{
// Unicode strings max. 32KB
if (s.Length > 0x7ffe) throw new ArgumentException("String too long");
LSA_UNICODE_STRING lus = new LSA_UNICODE_STRING();
lus.Buffer = s;
lus.Length = (ushort)(s.Length * sizeof(char));
lus.MaximumLength = (ushort)(lus.Length + sizeof(char));
return lus;
}
}
public class LsaWrapperCaller
{
public static void AddPrivilege(string account, string privilege)
{
using (LsaWrapper lsaWrapper = new LsaWrapper())
{
lsaWrapper.AddPrivilege(account, privilege);
}
}
public static void RemovePrivilege(string account, string privilege)
{
using (LsaWrapper lsaWrapper = new LsaWrapper())
{
lsaWrapper.RemovePrivilege(account, privilege);
}
}
}
}
2018-03-21 03:34:42,613 1340 [DEBUG] -
using System;
namespace MyLsaWrapper
{
using System.Runtime.InteropServices;
using System.Security;
using System.ComponentModel;
using System.Security.Principal;
using LSA_HANDLE = IntPtr;
[StructLayout(LayoutKind.Sequential)]
struct LSA_OBJECT_ATTRIBUTES
{
internal int Length;
internal IntPtr RootDirectory;
internal IntPtr ObjectName;
internal int Attributes;
internal IntPtr SecurityDescriptor;
internal IntPtr SecurityQualityOfService;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
struct LSA_UNICODE_STRING
{
internal ushort Length;
internal ushort MaximumLength;
[MarshalAs(UnmanagedType.LPWStr)]
internal string Buffer;
}
sealed class Win32Sec
{
[DllImport("advapi32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaOpenPolicy(
LSA_UNICODE_STRING[] SystemName,
ref LSA_OBJECT_ATTRIBUTES ObjectAttributes,
int AccessMask,
out IntPtr PolicyHandle
);
[DllImport("advapi32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaAddAccountRights(
LSA_HANDLE PolicyHandle,
IntPtr pSID,
LSA_UNICODE_STRING[] UserRights,
int CountOfRights
);
[DllImport("advapi32", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaRemoveAccountRights(
LSA_HANDLE PolicyHandle,
IntPtr pSID,
bool AllRights,
LSA_UNICODE_STRING[] UserRights,
int CountOfRights
);
[DllImport("advapi32")]
internal static extern int LsaNtStatusToWinError(int NTSTATUS);
[DllImport("advapi32")]
internal static extern int LsaClose(IntPtr PolicyHandle);
}
internal sealed class Sid : IDisposable
{
public IntPtr pSid = IntPtr.Zero;
public System.Security.Principal.SecurityIdentifier sid = null;
public Sid(string account)
{
try { sid = new SecurityIdentifier(account); }
catch { sid = (SecurityIdentifier)(new NTAccount(account)).Translate(typeof(SecurityIdentifier)); }
Byte[] buffer = new Byte[sid.BinaryLength];
sid.GetBinaryForm(buffer, 0);
pSid = Marshal.AllocHGlobal(sid.BinaryLength);
Marshal.Copy(buffer, 0, pSid, sid.BinaryLength);
}
public void Dispose()
{
if (pSid != IntPtr.Zero)
{
Marshal.FreeHGlobal(pSid);
pSid = IntPtr.Zero;
}
GC.SuppressFinalize(this);
}
~Sid() { Dispose(); }
}
public sealed class LsaWrapper : IDisposable
{
enum Access : int
{
POLICY_READ = 0x20006,
POLICY_ALL_ACCESS = 0x00F0FFF,
POLICY_EXECUTE = 0X20801,
POLICY_WRITE = 0X207F8
}
const uint STATUS_ACCESS_DENIED = 0xc0000022;
const uint STATUS_INSUFFICIENT_RESOURCES = 0xc000009a;
const uint STATUS_NO_MEMORY = 0xc0000017;
const uint STATUS_OBJECT_NAME_NOT_FOUND = 0xc0000034;
const uint STATUS_NO_MORE_ENTRIES = 0x8000001a;
IntPtr lsaHandle;
public LsaWrapper() : this(null) { } // local system if systemName is null
public LsaWrapper(string systemName)
{
LSA_OBJECT_ATTRIBUTES lsaAttr;
lsaAttr.RootDirectory = IntPtr.Zero;
lsaAttr.ObjectName = IntPtr.Zero;
lsaAttr.Attributes = 0;
lsaAttr.SecurityDescriptor = IntPtr.Zero;
lsaAttr.SecurityQualityOfService = IntPtr.Zero;
lsaAttr.Length = Marshal.SizeOf(typeof(LSA_OBJECT_ATTRIBUTES));
lsaHandle = IntPtr.Zero;
LSA_UNICODE_STRING[] system = null;
if (systemName != null)
{
system = new LSA_UNICODE_STRING[1];
system[0] = InitLsaString(systemName);
}
uint ret = Win32Sec.LsaOpenPolicy(system, ref lsaAttr, (int)Access.POLICY_ALL_ACCESS, out lsaHandle);
if (ret == 0) return;
if (ret == STATUS_ACCESS_DENIED) throw new UnauthorizedAccessException();
if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY)) throw new OutOfMemoryException();
throw new Win32Exception(Win32Sec.LsaNtStatusToWinError((int)ret));
}
public void AddPrivilege(string account, string privilege)
{
uint ret = 0;
using (Sid sid = new Sid(account))
{
LSA_UNICODE_STRING[] privileges = new LSA_UNICODE_STRING[1];
privileges[0] = InitLsaString(privilege);
ret = Win32Sec.LsaAddAccountRights(lsaHandle, sid.pSid, privileges, 1);
}
if (ret == 0) return;
if (ret == STATUS_ACCESS_DENIED) throw new UnauthorizedAccessException();
if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY)) throw new OutOfMemoryException();
throw new Win32Exception(Win32Sec.LsaNtStatusToWinError((int)ret));
}
public void RemovePrivilege(string account, string privilege)
{
uint ret = 0;
using (Sid sid = new Sid(account))
{
LSA_UNICODE_STRING[] privileges = new LSA_UNICODE_STRING[1];
privileges[0] = InitLsaString(privilege);
ret = Win32Sec.LsaRemoveAccountRights(lsaHandle, sid.pSid, false, privileges, 1);
}
if (ret == 0) return;
if (ret == STATUS_ACCESS_DENIED) throw new UnauthorizedAccessException();
if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY)) throw new OutOfMemoryException();
throw new Win32Exception(Win32Sec.LsaNtStatusToWinError((int)ret));
}
public void Dispose()
{
if (lsaHandle != IntPtr.Zero)
{
Win32Sec.LsaClose(lsaHandle);
lsaHandle = IntPtr.Zero;
}
GC.SuppressFinalize(this);
}
~LsaWrapper() { Dispose(); }
// helper functions:
static LSA_UNICODE_STRING InitLsaString(string s)
{
// Unicode strings max. 32KB
if (s.Length > 0x7ffe) throw new ArgumentException("String too long");
LSA_UNICODE_STRING lus = new LSA_UNICODE_STRING();
lus.Buffer = s;
lus.Length = (ushort)(s.Length * sizeof(char));
lus.MaximumLength = (ushort)(lus.Length + sizeof(char));
return lus;
}
}
public class LsaWrapperCaller
{
public static void AddPrivilege(string account, string privilege)
{
using (LsaWrapper lsaWrapper = new LsaWrapper())
{
lsaWrapper.AddPrivilege(account, privilege);
}
}
public static void RemovePrivilege(string account, string privilege)
{
using (LsaWrapper lsaWrapper = new LsaWrapper())
{
lsaWrapper.RemovePrivilege(account, privilege);
}
}
}
}
2018-03-21 03:34:42,785 1340 [INFO ] - Probing for possible conflicts with SSHD server to be configured on port 22 ...
2018-03-21 03:34:45,042 1340 [INFO ] - Hashes for internal source match
2018-03-21 03:34:45,073 1340 [INFO ] - C:\Program Files\OpenSSH-Win64
2018-03-21 03:34:45,104 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\FixHostFilePermissions.ps1
2018-03-21 03:34:45,136 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\FixUserFilePermissions.ps1
2018-03-21 03:34:45,167 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\install-sshd.ps1
2018-03-21 03:34:45,198 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\libcrypto.dll
2018-03-21 03:34:45,229 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\OpenSSHUtils.psd1
2018-03-21 03:34:45,261 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\OpenSSHUtils.psm1
2018-03-21 03:34:45,292 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\scp.exe
2018-03-21 03:34:45,323 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\sftp-server.exe
2018-03-21 03:34:45,339 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\sftp.exe
2018-03-21 03:34:45,370 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\ssh-add.exe
2018-03-21 03:34:45,401 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\ssh-agent.exe
2018-03-21 03:34:45,433 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\ssh-keygen.exe
2018-03-21 03:34:45,464 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\ssh-keyscan.exe
2018-03-21 03:34:45,495 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\ssh-shellhost.exe
2018-03-21 03:34:45,526 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\ssh.exe
2018-03-21 03:34:45,558 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\sshd.exe
2018-03-21 03:34:45,573 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\sshd_config_default
2018-03-21 03:34:45,604 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\uninstall-sshd.ps1
2018-03-21 03:34:45,651 1340 [INFO ] - C:\Program Files\OpenSSH-Win64\Set-SSHDefaultShell.ps1
2018-03-21 03:34:45,683 1340 [DEBUG] - Running Install-ChocolateyPath -pathToInstall 'C:\Program Files\OpenSSH-Win64' -pathType 'Machine'
2018-03-21 03:34:45,714 1340 [DEBUG] - Running Update-SessionEnvironment
2018-03-21 03:34:45,745 1340 [INFO ] - VERBOSE: Refreshing environment variables from the registry.
2018-03-21 03:34:45,886 1340 [INFO ] - PATH environment variable does not have C:\Program Files\OpenSSH-Win64 in it. Adding...
2018-03-21 03:34:45,917 1340 [INFO ] - VERBOSE: Choosing not to expand environment names
2018-03-21 03:34:45,964 1340 [DEBUG] - Test-ProcessAdminRights: returning True
2018-03-21 03:34:46,011 1340 [DEBUG] - Running Set-EnvironmentVariable -Name 'Path' -Value '%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;c:\ezsops\choco\bin;C:\Program Files\OpenSSL\bin;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files\OpenSSH-Win64;' -Scope 'Machine'
2018-03-21 03:34:46,042 1340 [DEBUG] - Registry type for Path is/will be ExpandString
2018-03-21 03:34:46,073 1340 [DEBUG] -
using System;
using System.Runtime.InteropServices;
namespace Win32
{
public class NativeMethods
{
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam,
uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
}
}
2018-03-21 03:34:46,104 1340 [WARN ] - WARNING: Failure attempting to let Explorer know about updated environment settings.
Could not find a part of the path 'C:\Windows\system32\config\systemprofile\AppData\Local\Temp\hvwowg5h.tmp'.
2018-03-21 03:34:46,120 1340 [DEBUG] - Running Update-SessionEnvironment
2018-03-21 03:34:46,120 1340 [INFO ] - VERBOSE: Refreshing environment variables from the registry.
2018-03-21 03:34:46,167 1340 [INFO ] - Updating machine environment variable TERM from "" to ""
2018-03-21 03:34:46,183 1340 [WARN ] - WARNING: You have specified SSHServerFeature - this machine is being configured as an SSH Server including opening port 22.
2018-03-21 03:34:46,198 1340 [INFO ] - Setting up SSH Logging
2018-03-21 03:34:46,214 1340 [WARN ] - WARNING: Explicitly disabling sshd logging as it currently logs about .5 GB / hour
2018-03-21 03:34:46,229 1340 [INFO ] - Current port setting in "C:\ProgramData\ssh\sshd_config" is "#Port 22", setting it to "Port 22"
2018-03-21 03:34:46,465 1340 [INFO ] - Ok.
2018-03-21 03:34:46,481 1340 [INFO ] -
2018-03-21 03:34:46,481 1340 [WARN ] - WARNING: The following private keys should be removed from the machine: ssh_host_dsa_key ssh_host_rsa_key ssh_host_ecdsa_key ssh_host_ed25519_key
2018-03-21 03:34:46,497 1340 [INFO ] - Ensuring all ssh key and configuration files have correct permissions for all users
2018-03-21 03:34:46,528 1340 [INFO ] - VERBOSE: Loading module from path 'C:\Program Files\OpenSSH-Win64\OpenSSHUtils.psd1'.
2018-03-21 03:34:46,544 1340 [INFO ] - VERBOSE: Loading module from path 'C:\Program Files\OpenSSH-Win64\OpenSSHUtils.psm1'.
2018-03-21 03:34:46,669 1340 [DEBUG] -
using System;
using System.Runtime.InteropServices;
public class AdjPriv
{
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
internal const int SE_PRIVILEGE_DISABLED = 0x00000000;
internal const int TOKEN_QUERY = 0x00000008;
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
public static bool EnablePrivilege(string privilege, bool disable)
{
bool retVal;
TokPriv1Luid tp;
IntPtr hproc = GetCurrentProcess();
IntPtr htok = IntPtr.Zero;
retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
tp.Count = 1;
tp.Luid = 0;
if(disable)
{
tp.Attr = SE_PRIVILEGE_DISABLED;
}
else
{
tp.Attr = SE_PRIVILEGE_ENABLED;
}
retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
return retVal;
}
}
2018-03-21 03:34:46,778 1340 [ERROR] - ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Could not find a part of the path 'C:\Windows\system32\config\systemprofile\AppData\Local\Temp\bnilzcf2.tmp'.
2018-03-21 03:34:46,872 1340 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'c:\ezsops\choco\helpers\chocolateyInstaller.psm1'; & 'c:\ezsops\choco\helpers\chocolateyScriptRunner.ps1' -packageScript 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1' -installArguments '' -packageParameters '/SSHServerFeature /SSHServerPort:22''] exited with '-1'.
2018-03-21 03:34:46,919 1340 [DEBUG] - Calling command ['"C:\Windows\System32\shutdown.exe" /a']
2018-03-21 03:34:46,965 1340 [DEBUG] - Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'
2018-03-21 03:34:47,012 1340 [WARN ] - Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
2018-03-21 03:34:47,044 1340 [DEBUG] - Logging of values is not turned on by default because it
could potentially expose sensitive data. If you understand the risk,
please see `choco feature -h` for information to turn it on.
2018-03-21 03:34:47,059 1340 [DEBUG] - The following values have been added/changed (may contain sensitive data):
2018-03-21 03:34:47,090 1340 [DEBUG] - * Path='[REDACTED]' (Machine)
2018-03-21 03:34:47,106 1340 [DEBUG] - * TERM='[REDACTED]' (Machine)
2018-03-21 03:34:47,184 1340 [DEBUG] - Capturing package files in 'c:\ezsops\choco\lib\openssh'
2018-03-21 03:34:47,231 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\openssh.nupkg'
with checksum '034E67A12C8DBC5FF1D678B74248737D'
2018-03-21 03:34:47,247 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\openssh.nuspec'
with checksum '7AC83CF25DD80EECA1E8BDE7DBD13FE8'
2018-03-21 03:34:47,278 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\7z.dll'
with checksum '9943B3BCB2CA91CCBEF2D96682CECB79'
2018-03-21 03:34:47,309 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\7z.exe'
with checksum '506E5B371882A5A62B669F04CE04DBA8'
2018-03-21 03:34:47,340 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\7z.exe.ignore'
with checksum 'D41D8CD98F00B204E9800998ECF8427E'
2018-03-21 03:34:47,372 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\barebonesinstaller.ps1'
with checksum '4DE2899C4EEA998C81887E5CDEF3D65F'
2018-03-21 03:34:47,387 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1'
with checksum 'FF65EE7FF05767221576F0D6C975A087'
2018-03-21 03:34:47,419 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\chocolateyuninstall.ps1'
with checksum '5A35DF1244BD5D1B425190EAFE869167'
2018-03-21 03:34:47,434 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\fileinuseutils.ps1'
with checksum 'C0E77A9DF72C650ADBCAEB717552E03A'
2018-03-21 03:34:47,465 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\Get-NetStat.ps1'
with checksum '5639E1A979924BAB1F81DEDC52C89003'
2018-03-21 03:34:47,497 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\LICENSE.txt'
with checksum '1FA7983BE13136F10B6E346AC0F8ACE3'
2018-03-21 03:34:47,528 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\OpenSSH-Win32.zip'
with checksum '5C4DBCE1F1F66D1A211394FB34B5C4CB'
2018-03-21 03:34:47,559 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\OpenSSH-Win64.zip'
with checksum '5AAAD11FC423F12FC342D5B0EB0C97E5'
2018-03-21 03:34:47,590 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\Set-SSHDefaultShell.ps1'
with checksum '1A26224C48488038D136D9F06A7B9E73'
2018-03-21 03:34:47,606 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\SetSpecialPrivileges.ps1'
with checksum '543B78A2B38141A98F2AF8BD3F10893B'
2018-03-21 03:34:47,637 1340 [DEBUG] - Found 'c:\ezsops\choco\lib\openssh\tools\VERIFICATION.txt'
with checksum 'A3C11FB5F52B25E893CFB4FA8539F2E4'
2018-03-21 03:34:47,653 1340 [DEBUG] - Attempting to create directory "c:\ezsops\choco\.chocolatey\openssh.7.6.0.1".
2018-03-21 03:34:47,669 1340 [DEBUG] - There was no original file at 'c:\ezsops\choco\.chocolatey\openssh.7.6.0.1\.files'
2018-03-21 03:34:47,669 1340 [DEBUG] - Attempting to delete file "c:\ezsops\choco\.chocolatey\openssh.7.6.0.1\.arguments".
2018-03-21 03:34:47,669 1340 [DEBUG] - Attempting to delete file "c:\ezsops\choco\.chocolatey\openssh.7.6.0.1\.extra".
2018-03-21 03:34:47,684 1340 [DEBUG] - Attempting to delete file "c:\ezsops\choco\.chocolatey\openssh.7.6.0.1\.version".
2018-03-21 03:34:47,684 1340 [DEBUG] - Attempting to delete file "c:\ezsops\choco\.chocolatey\openssh.7.6.0.1\.sxs".
2018-03-21 03:34:47,684 1340 [DEBUG] - Attempting to delete file "c:\ezsops\choco\.chocolatey\openssh.7.6.0.1\.pin".
2018-03-21 03:34:47,684 1340 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
2018-03-21 03:34:47,684 1340 [ERROR] - The install of openssh was NOT successful.
2018-03-21 03:34:47,700 1340 [ERROR] - Error while running 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1'.
See log for details.
2018-03-21 03:34:47,700 1340 [DEBUG] - Attempting to create directory "c:\ezsops\choco\lib-bad".
2018-03-21 03:34:47,715 1340 [DEBUG] - Moving 'c:\ezsops\choco\lib\openssh'
to 'c:\ezsops\choco\lib-bad\openssh'
2018-03-21 03:34:49,732 1340 [DEBUG] - Attempting to delete file "C:\Windows\system32\config\systemprofile\AppData\Local\NuGet\Cache\openssh.7.6.0.1.nupkg".
2018-03-21 03:34:49,732 1340 [WARN ] -
Chocolatey installed 0/1 packages. 1 packages failed.
See the log for details (c:\ezsops\choco\logs\chocolatey.log).
2018-03-21 03:34:49,748 1340 [INFO ] -
2018-03-21 03:34:49,748 1340 [ERROR] - Failures
2018-03-21 03:34:49,764 1340 [ERROR] - - openssh (exited -1) - Error while running 'c:\ezsops\choco\lib\openssh\tools\chocolateyinstall.ps1'.
See log for details.
2018-03-21 03:34:49,764 1340 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2018-03-21 03:34:49,779 1340 [DEBUG] - Exiting with -1
## These are the relevant parts of the original DSC configuration
Configuration Prepare-RDGW
{
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'PackageManagement' -ModuleVersion 1.1.7.0
Import-DscResource -ModuleName 'cChoco'
Node localhost
{
## Install Chocolatey itself
cChocoInstaller installChoco
{
DependsOn = '[File]mkdirEzsOps'
InstallDir = 'c:\myops\choco'
}
cChocoPackageInstaller installOpenSSHServer
{
DependsOn = "[cChocoInstaller]installChoco"
Ensure = 'Present'
Name = 'openssh'
Params = "/SSHServerFeature /SSHServerPort:22"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment