From 2d6e648a8f268b6b9b1dbb2994e1d3217bd69f14 Mon Sep 17 00:00:00 2001 From: manojampalam Date: Sat, 14 May 2016 23:21:33 -0700 Subject: [PATCH] 5-14 C6 --- contrib/win32/openssh/Win32-OpenSSH.sln | 17 ----------------- contrib/win32/openssh/install-sshd.ps1 | 16 ++++++++++++++-- contrib/win32/openssh/install-sshlsa.ps1 | 10 ++++++++++ contrib/win32/openssh/uninstall-sshd.ps1 | 12 ++++++++++++ contrib/win32/openssh/uninstall-sshlsa.ps1 | 10 ++++++++++ 5 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 contrib/win32/openssh/install-sshlsa.ps1 create mode 100644 contrib/win32/openssh/uninstall-sshlsa.ps1 diff --git a/contrib/win32/openssh/Win32-OpenSSH.sln b/contrib/win32/openssh/Win32-OpenSSH.sln index 637236d2..b43a47a5 100644 --- a/contrib/win32/openssh/Win32-OpenSSH.sln +++ b/contrib/win32/openssh/Win32-OpenSSH.sln @@ -95,15 +95,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-add", "ssh-add.vcxproj" {8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssh-pubkey", "ssh-pubkey.vcxproj", "{029797FF-C986-43DE-95CD-2E771E86A0AD}" - ProjectSection(ProjectDependencies) = postProject - {05E1115F-8529-46D0-AAAF-52A404CE79A7} = {05E1115F-8529-46D0-AAAF-52A404CE79A7} - {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} = {8F9D3B74-8D33-448E-9762-26E8DCC6B2F4} - {DD483F7D-C553-4740-BC1A-903805AD0174} = {DD483F7D-C553-4740-BC1A-903805AD0174} - {0D02F0F0-013B-4EE3-906D-86517F3822C0} = {0D02F0F0-013B-4EE3-906D-86517F3822C0} - {8660C2FE-9874-432D-B047-E042BB41DBE0} = {8660C2FE-9874-432D-B047-E042BB41DBE0} - EndProjectSection -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -232,14 +223,6 @@ Global {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x64.Build.0 = Release|x64 {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.ActiveCfg = Release|Win32 {029797FF-C986-43DE-95CD-2E771E86AEBC}.Release|x86.Build.0 = Release|Win32 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Debug|x64.ActiveCfg = Debug|x64 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Debug|x64.Build.0 = Debug|x64 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Debug|x86.ActiveCfg = Debug|Win32 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Debug|x86.Build.0 = Debug|Win32 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Release|x64.ActiveCfg = Release|x64 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Release|x64.Build.0 = Release|x64 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Release|x86.ActiveCfg = Release|Win32 - {029797FF-C986-43DE-95CD-2E771E86A0AD}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/contrib/win32/openssh/install-sshd.ps1 b/contrib/win32/openssh/install-sshd.ps1 index 608a936f..2f174ca6 100644 --- a/contrib/win32/openssh/install-sshd.ps1 +++ b/contrib/win32/openssh/install-sshd.ps1 @@ -2,6 +2,7 @@ $scriptdir = Split-Path $scriptpath $sshdpath = Join-Path $scriptdir "sshd.exe" +$sshagentpath = Join-Path $scriptdir "ssh-agent.exe" if (-not (Test-Path $sshdpath)) { throw "sshd.exe is not present in script path" @@ -13,5 +14,16 @@ if (Get-Service sshd -ErrorAction SilentlyContinue) sc.exe delete sshd 1> null } -New-Service -Name sshd -BinaryPathName $sshdpath -Description "SSH Deamon" -StartupType Manual | Out-Null -Write-Host -ForegroundColor Green "sshd successfully installed" +if (Get-Service ssh-agent -ErrorAction SilentlyContinue) +{ + Stop-Service ssh-agent + sc.exe delete ssh-agent 1> null +} + +New-Service -Name ssh-agent -BinaryPathName $sshagentpath -Description "SSH Agent" -StartupType Manual | 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)' + +New-Service -Name sshd -BinaryPathName $sshdpath -Description "SSH Deamon" -StartupType Manual -DependsOn ssh-agent | Out-Null +sc.exe config sshd obj= "NT SERVICE\SSHD" +Write-Host -ForegroundColor Green "sshd and ssh-agent services successfully installed" + diff --git a/contrib/win32/openssh/install-sshlsa.ps1 b/contrib/win32/openssh/install-sshlsa.ps1 new file mode 100644 index 00000000..887dd2c0 --- /dev/null +++ b/contrib/win32/openssh/install-sshlsa.ps1 @@ -0,0 +1,10 @@ +copy .\ssh-lsa.dll $env:windir\system32 +$subkey = 'SYSTEM\CurrentControlSet\Control\Lsa' +$value = 'Authentication Packages' +$reg = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 0) +$key = $reg.OpenSubKey($subkey, $true) +$arr = $key.GetValue($value) +if ($arr -notcontains 'ssh-lsa') { + $arr += 'ssh-lsa' + $key.SetValue($value, [string[]]$arr, 'MultiString') +} diff --git a/contrib/win32/openssh/uninstall-sshd.ps1 b/contrib/win32/openssh/uninstall-sshd.ps1 index bd10780d..8f0cd90f 100644 --- a/contrib/win32/openssh/uninstall-sshd.ps1 +++ b/contrib/win32/openssh/uninstall-sshd.ps1 @@ -8,3 +8,15 @@ else { Write-Host -ForegroundColor Yellow "sshd service is not installed" } +if (Get-Service ssh-agent -ErrorAction SilentlyContinue) +{ + Stop-Service ssh-agent + sc.exe delete ssh-agent 1>null + Write-Host -ForegroundColor Green "ssh-agent successfully uninstalled" +} +else { + Write-Host -ForegroundColor Yellow "ssh-agent service is not installed" +} + + + diff --git a/contrib/win32/openssh/uninstall-sshlsa.ps1 b/contrib/win32/openssh/uninstall-sshlsa.ps1 new file mode 100644 index 00000000..c99390ca --- /dev/null +++ b/contrib/win32/openssh/uninstall-sshlsa.ps1 @@ -0,0 +1,10 @@ +$subkey = 'SYSTEM\CurrentControlSet\Control\Lsa' +$value = 'Authentication Packages' +$reg = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine', 0) +$key = $reg.OpenSubKey($subkey, $true) +$arr = $key.GetValue($value) +if ($arr -contains 'ssh-lsa') { + $tempArryList = New-Object System.Collections.Arraylist(,$arr) + $tempArryList.Remove('ssh-lsa') + $key.SetValue($value, [string[]]$tempArryList, 'MultiString') +}