0

I am trying to install Open-SSH on my Windows 10 pc in order to connect to it from my linux machine with ssh. I am following this tutorial, but as soon as I have to run something like Start-Service ssh-agent, it says that the service doesn't exist. Another thing that doesn't work is Install-Module -Force OpenSSHUtils, and it says that the signature of the file 'OpenSSHUtils.psd1' is not valid. I have tried many other tutorials, uninstalling everything before each one, and none of them are working. Is there any way to install these things manually? Am I missing an important step of the installation?

SpencerLS
  • 361
  • 5
  • 16
  • 1
    If you don't install the module properly then it's likely nothing is going to work. What is the result if you run the following command? Get-ExecutionPolicy. Also which method did you use to install? Powershell/DISM/Windows Features? – Scepticalist Apr 17 '20 at 17:14
  • @Scepticalist When I run that command it says Unrestricted. (I am using Administrator privileges) I have tried all three of those methods, but I feel like I got the furthest using Powershell – SpencerLS Apr 17 '20 at 20:34
  • This question has nothing to do with a coding problem in Powershell. – bluuf Apr 18 '20 at 09:40

1 Answers1

1

You do know you can install SSH directly in Windows 10 by using Add Feature option, correct? No need to download an external module/tool unless the builtin one does not provide all you are after.

Installation of OpenSSH For Windows Server 2019 and Windows 10

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Using the GUI

How to Enable and Use Windows 10’s New Built-in SSH Commands

Yet, if you do decide to use external stuff, then, Always test destructive (CUD = Create, Update, delete) code before true implementation.

Find-Module -Name 'OpenSSHUtils' -Verbose

<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.

Version              Name                                Repository           Description                                                                                                           
-------              ----                                ----------           -----------                                                                                                           
1.0.0.1              OpenSSHUtils                        PSGallery            Configure OpenSSH for Windows related security settings like file owner and permissions. 
#>


Find-Module -Name 'OpenSSHUtils' -Verbose | 
Save-Module -Path "$env:USERPROFILE\Documents\WindowsPowerShell\Modules" -Verbose -WhatIf
<#
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Save Package" on target "'OpenSSHUtils' to location 'C:\Users\Daniel\Documents\WindowsPowerShell\Modules'".
#>

Install-Module -Name 'OpenSSHUtils' -Verbose -WhatIf

<#
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='OpenSSHUtils'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'OpenSSHUtils'.
What if: Performing the operation "Install-Module" on target "Version '1.0.0.1' of module 'OpenSSHUtils'".
#>
postanote
  • 15,138
  • 2
  • 14
  • 25
  • I followed all of the commands, but `Install-Module -Name 'OpenSSHUtils' -Verbose gives this error: `The module 'OpenSSHUtils' cannot be installed or updated because the authenticode signature of the file 'OpenSSHUtils.psd1' is not valid.` Also, I followed microsoft's tutorial and when it says to do this: `Start-Service sshd # OPTIONAL but recommended: Set-Service -Name sshd -StartupType 'Automatic'` it doesn't do anything because the service doesn't exist. There aren't any services even related to ssh or sshd. – SpencerLS Apr 20 '20 at 01:49
  • You can download the module manually from here: https://www.powershellgallery.com/packages/OpenSSHUtils/1.0.0.1. Open the NuPkg with winzip or similar and copy the folder to your modules folder. Then see if Import-module works. – Scepticalist Apr 24 '20 at 19:00