Skip to content

install-sshd.ps1 is not valid for many environments #880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gravcat opened this issue Sep 11, 2017 · 5 comments
Closed

install-sshd.ps1 is not valid for many environments #880

gravcat opened this issue Sep 11, 2017 · 5 comments

Comments

@gravcat
Copy link

gravcat commented Sep 11, 2017

Please answer the following

"OpenSSH for Windows" version
0.0.20.0 (and earlier)

Server OperatingSystem
Microsoft Windows [Version 10.0.15063] (Windows 10)

Client OperatingSystem
Microsoft Windows [Version 10.0.15063] (Windows 10)

What is failing
install-sshd.ps1 does not execute on Windows 10 via Azure's Custom Script Extension, a method to run a script on a virtual machine. Mostly used for "bootstrap" operations and whatnot.

Expected output
Successful sshd service and supporting related resources installed and ready.

Actual output
install-sshd.ps1 fails for a variety of reasons, one of which prevents LSAWrapper being available for the script to use.

@gravcat
Copy link
Author

gravcat commented Sep 11, 2017

I can't find install-sshd.ps1 in your repository, so I'll just have to describe as best I can.

Around line 220 in install-sshd.ps1, there is an if conditional which checks the powershell edition.

if(($psversiontable.Containskey("psedition")) -and ($psversiontable.PSEdition -ieq "core"))
    $references = "System.Security.Principal.Windows", "Microsoft.Win32.Primitives"
}

try {
    $null = [MyLsaWrapper.LsaWrapperCaller]
}
catch {
    $types = Add-Type $definition -ref $references -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}

Unfortunately this is not valid for many platforms, including my Windows 10 systems. We require Windows 10 because we are using the latest advancements with the Windows Subsystem for Linux. I suggest that the check include the other PSEditions that may be encountered, or to have the check removed entirely.

$psversiontable.PSEdition evaluates to Desktop on Windows 10, and Server on Windows Server (non-core).

Because this conditional is not met and the block inside it is not executed, $definitions is not set and thus MyLSAWrapper is not available for use.

If this were resolved, this would allow me to get one step closer to fully automating Win32-OpenSSH deployments!

@manojampalam
Copy link
Contributor

Thanks @gravcat. Did you evaluate the Chocolatey version of this package? install-sshd.ps1 is supposed to be a bare bones installer until we have an official supported version. @joeyaiello may have some input here.

@gravcat
Copy link
Author

gravcat commented Sep 13, 2017

Here's the link to the repository, and a link to the Chocolatey page for it.

  1. https://github.com/DarwinJS/ChocoPackages/tree/master/openssh
  2. https://chocolatey.org/packages/openssh

If there's a better way to be doing this I'll happily oblige! I actually ended up working with the Azure team to determine the cause of the fault in install-sshd.ps1 so I'm very committed!

It just seems that install-sshd.ps1 is so close to working for what many would need.

@bingbing8 bingbing8 self-assigned this Sep 27, 2017
@bingbing8
Copy link
Contributor

bingbing8 commented Sep 27, 2017

@gravcat , what is the value of $psversiontable.PSEdition on your system? this is to determine the version of powershell. On full powershell, those reference already been loaded so there is no need to add the reference.

Removing the condition and add unnecessary reference does not work on win2k12r2 full sku machine.

bingbing8 added a commit to PowerShell/openssh-portable that referenced this issue Sep 28, 2017
manojampalam pushed a commit to PowerShell/openssh-portable that referenced this issue Sep 28, 2017
@gravcat
Copy link
Author

gravcat commented Oct 10, 2017

Hi @bingbing8,

The $psversiontable.PSEdition = Desktop on Windows 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants