{"id":7969,"date":"2020-12-16T16:13:23","date_gmt":"2020-12-16T21:13:23","guid":{"rendered":"https:\/\/jdhitsolutions.com\/blog\/?p=7969"},"modified":"2020-12-16T16:18:33","modified_gmt":"2020-12-16T21:18:33","slug":"deploy-openssh-server-to-windows-10","status":"publish","type":"post","link":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/","title":{"rendered":"Deploy OpenSSH Server to Windows 10"},"content":{"rendered":"\n<p>PowerShell 7 offers a number of compelling reasons to adopt it. One of the best is support for SSH as a PowerShell remoting protocol. Unfortunately, this is not a topic that typically comes up for Windows-centric IT Pros. I know this is definitely true in my case, and a deficiency I have been working on. On the plus side, Windows 10 ships with the OpenSSH client installed and ready to go. But what about the  OpenSSH Server? On Windows platforms, you need to enable and configure this element if you want to use SSH remoting in PowerShell. Naturally, I'd like to do this with PowerShell and also remotely. First up, I want to show you how to setup the OpenSSH Server component on Windows 10.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Manual Setup<\/h2>\n\n\n\n<p>The PowerShell commands for installing the OpenSSH Server component in Windows 10 are pretty simple. First, I need the capability. I'm running these commands interactively.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Get-WindowsCapability -online -name openssh.server* | Add-WindowsCapability -online<\/code><\/pre>\n\n\n\n<p>I'm using Get-WindowsCapability with a wildcard just in case the version number changes at some point. I can see this worked.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"306\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1024x306.png\" alt=\"OpenSSH.Server installed\" class=\"wp-image-7970\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1024x306.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-300x90.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-768x230.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1536x459.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-850x254.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png 1656w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>This will setup the sshd service which is not running and configured to start manually. I want to configure the service to start and start automatically.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Set-Service&nbsp;-Name&nbsp;sshd&nbsp;-StartupType&nbsp;Automatic\nStart-Service&nbsp;-Name&nbsp;sshd<\/code><\/pre>\n\n\n\n<p>One thing I have learned about ssh, especially if you want to use it with PowerShell remoting, and that is to verify ssh works outside of PowerShell. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">ssh localhost<\/code><\/pre>\n\n\n\n<p>You might get prompted about accepting keys and for a password. If you're setup is like mine, you'll end up in a CMD prompt.  But maybe you'd like a different shell when connecting over ssh. Note that I am <strong>not <\/strong>talking about PowerShell remoting over ssh yet. You can modify the registry on your computer.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$regPath&nbsp;=&nbsp;\"HKLM:\\SOFTWARE\\OpenSSH\\\"\n$regProperty&nbsp;=&nbsp;\"DefaultShell\"\n$regValue&nbsp;=&nbsp;(Get-Command&nbsp;powershell.exe).source\nSet-ItemProperty&nbsp;-Path&nbsp;$regPath&nbsp;-Name&nbsp;$regProperty&nbsp;-Value&nbsp;$regValue<\/code><\/pre>\n\n\n\n<p>The change should be immediate and not require restarting the sshd service. Using ssh to connect to localhost now gives me a Windows PowerShell session. It wouldn't take much to assemble a simple PowerShell script to run these commands interactively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remote Installation<\/h2>\n\n\n\n<p>But I want to do this remotely. I have some Windows 10 VMs that I'd like to connect to with ssh. I will need to use traditional PowerShell remoting. Yes, you could use a third-party tool like psexec.exe or something like Desired State Configuration, but I want to stick with tools and skills you likely already have.<\/p>\n\n\n\n<p>As I was working on this I had a simple PowerShell script that ran the steps I just showed you. I figured all I needed to do was run the script using Invoke-Command. Nope. Turns out the Add-WindowsCapability command will not work in a remoting session. This is apparently a known limitation with feature-on-demand installation. But I wasn't going to let that stop me. My eventual workaround was to create a temporary scheduled task that would add OpenSSH.Server as SYSTEM.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">$Time&nbsp;=&nbsp;New-ScheduledTaskTrigger&nbsp;-At&nbsp;23:59&nbsp;-Once\n$User&nbsp;=&nbsp;New-ScheduledTaskPrincipal&nbsp;System\n$action&nbsp;=&nbsp;New-ScheduledTaskAction&nbsp;-Execute&nbsp;\"PowerShell.exe\"&nbsp;-Argument&nbsp;'-noprofile&nbsp;-command&nbsp;\"&amp;&nbsp;{&nbsp;Get-WindowsCapability&nbsp;-online&nbsp;-name&nbsp;openssh.server*&nbsp;|&nbsp;Add-WindowsCapability&nbsp;-online}\"'\n$tmpTask&nbsp;=&nbsp;Register-ScheduledTask&nbsp;-taskpath&nbsp;\\&nbsp;-TaskName&nbsp;\"AddTask\"&nbsp;-Trigger&nbsp;$Time&nbsp;-Principal&nbsp;$user&nbsp;-Action&nbsp;$Action\nStart-ScheduledTask&nbsp;-TaskName&nbsp;AddTask\n\n<em>#give&nbsp;the&nbsp;task&nbsp;a&nbsp;chance&nbsp;to&nbsp;finish<\/em>\nStart-Sleep&nbsp;-Seconds&nbsp;20\n\n$tmpTask&nbsp;|&nbsp;Unregister-ScheduledTask&nbsp;-confirm:$false<\/code><\/pre>\n\n\n\n<p>The trigger time is irrelevant because I'm going to manually start the task and then remove it As long as I'm not running this close to midnight, I should be fine.<\/p>\n\n\n\n<p>I also wanted my script to support -WhatIf and offer Verbose output, even though the code was running remotely. Here's the script I came up with.<\/p>\n\n\n\n<pre title=\"Setup-SSHServer.ps1\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\"><em>#requires&nbsp;-version&nbsp;5.1<\/em>\n\n<em>&lt;#<\/em>\n<em>This&nbsp;is&nbsp;used&nbsp;to&nbsp;setup&nbsp;SSHD&nbsp;on&nbsp;a&nbsp;Windows&nbsp;10&nbsp;Client&nbsp;through&nbsp;PowerShell&nbsp;remoting<\/em>\n\n<em>Sample&nbsp;usage<\/em>\n<em>Verbose&nbsp;and&nbsp;Whatif<\/em>\n<em>invoke-command&nbsp;-FilePath&nbsp;.\\Setup-SSHServer.ps1&nbsp;-ComputerName&nbsp;win10&nbsp;-cred&nbsp;$artd&nbsp;-ArgumentList&nbsp;@(\"Continue\",$True)<\/em>\n\n<em>Verbose<\/em>\n<em>invoke-command&nbsp;-FilePath&nbsp;.\\Setup-SSHServer.ps1&nbsp;-ComputerName&nbsp;win10&nbsp;-cred&nbsp;$artd&nbsp;-ArgumentList&nbsp;@(\"Continue\")<\/em>\n<em>#&gt;<\/em>\n\n[cmdletbinding(<em>SupportsShouldProcess<\/em>)]\nparam&nbsp;([string]$VerboseOption&nbsp;=&nbsp;\"SilentlyContinue\",&nbsp;[bool]$WhatIfOption&nbsp;=&nbsp;$False)\n\n$VerbosePreference&nbsp;=&nbsp;$VerboseOption\n$WhatIfPreference&nbsp;=&nbsp;$WhatIfOption\n\nWrite-Verbose&nbsp;\"Starting&nbsp;SSHD&nbsp;setup&nbsp;process\"\nTry&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Testing&nbsp;for&nbsp;sshd&nbsp;service\"\n&nbsp;&nbsp;&nbsp;&nbsp;$svc&nbsp;=&nbsp;Get-Service&nbsp;-Name&nbsp;sshd&nbsp;-ErrorAction&nbsp;Stop\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($svc.status&nbsp;-eq&nbsp;'Running')&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"sshd&nbsp;service&nbsp;appears&nbsp;to&nbsp;be&nbsp;installed&nbsp;and&nbsp;running\"\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Warning&nbsp;\"sshd&nbsp;service&nbsp;found&nbsp;but&nbsp;it&nbsp;isn't&nbsp;running\"\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;<em>#take&nbsp;no&nbsp;further&nbsp;action<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;Return&nbsp;\"OpenSSH&nbsp;Server&nbsp;installation&nbsp;appears&nbsp;to&nbsp;be&nbsp;complete.\"\n}\nCatch&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"sshd&nbsp;service&nbsp;not&nbsp;found.&nbsp;Continuing&nbsp;with&nbsp;installation\"\n}\n\nWrite-Verbose&nbsp;\"Testing&nbsp;OpenSSH.Server&nbsp;Windows&nbsp;capability\"\nif&nbsp;(-Not&nbsp;$svc)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;Try&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cap&nbsp;=&nbsp;Get-WindowsCapability&nbsp;-Name&nbsp;OpenSSH.Server*&nbsp;-Online&nbsp;-ErrorAction&nbsp;Stop\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cap&nbsp;|&nbsp;Out-String&nbsp;|&nbsp;Write-Verbose\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;Catch&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Throw&nbsp;$_\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n\nif&nbsp;($cap.State&nbsp;-eq&nbsp;'NotPresent'&nbsp;-And&nbsp;$cap.name&nbsp;-match&nbsp;\"OpenSSH\")&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;<em>#install&nbsp;capability<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;Try&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Adding&nbsp;$($cap.name)\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($pscmdlet.ShouldProcess($cap.Name))&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>#installing&nbsp;with&nbsp;a&nbsp;Scheduledtask&nbsp;as&nbsp;System&nbsp;to&nbsp;get&nbsp;around&nbsp;the&nbsp;limitation<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>#with&nbsp;Add-WindowsCapability&nbsp;in&nbsp;a&nbsp;PowerShell&nbsp;remoting&nbsp;session<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Time&nbsp;=&nbsp;New-ScheduledTaskTrigger&nbsp;-At&nbsp;23:59&nbsp;-Once\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$User&nbsp;=&nbsp;New-ScheduledTaskPrincipal&nbsp;System\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$action&nbsp;=&nbsp;New-ScheduledTaskAction&nbsp;-Execute&nbsp;\"PowerShell.exe\"&nbsp;-Argument&nbsp;'-noprofile&nbsp;-command&nbsp;\"&amp;&nbsp;{&nbsp;Get-WindowsCapability&nbsp;-online&nbsp;-name&nbsp;openssh.server*&nbsp;|&nbsp;Add-WindowsCapability&nbsp;-online}\"'\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tmpTask&nbsp;=&nbsp;Register-ScheduledTask&nbsp;-taskpath&nbsp;\\&nbsp;-TaskName&nbsp;\"AddTask\"&nbsp;-Trigger&nbsp;$Time&nbsp;-Principal&nbsp;$user&nbsp;-Action&nbsp;$Action\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start-ScheduledTask&nbsp;-TaskName&nbsp;AddTask\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>#give&nbsp;the&nbsp;task&nbsp;a&nbsp;chance&nbsp;to&nbsp;finish<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start-Sleep&nbsp;-Seconds&nbsp;20\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tmpTask&nbsp;|&nbsp;Unregister-ScheduledTask&nbsp;-confirm:$false\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<em>#Whatif<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp;&nbsp;&nbsp;&nbsp;Catch&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Throw&nbsp;$_\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\n\nWrite-Verbose&nbsp;\"Set&nbsp;sshd&nbsp;to&nbsp;auto&nbsp;start\"\nTry&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($pscmdlet.ShouldProcess(\"sshd\",&nbsp;\"Configure&nbsp;service\"))&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set-Service&nbsp;-Name&nbsp;sshd&nbsp;-StartupType&nbsp;Automatic&nbsp;-ErrorAction&nbsp;stop\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Start&nbsp;the&nbsp;sshd&nbsp;service\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start-Service&nbsp;-Name&nbsp;sshd&nbsp;-ErrorAction&nbsp;Stop\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get-Service&nbsp;sshd&nbsp;|&nbsp;Select-Object&nbsp;-Property&nbsp;*&nbsp;|&nbsp;Out-String&nbsp;|&nbsp;Write-Verbose\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}\nCatch&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Warning&nbsp;\"There&nbsp;was&nbsp;a&nbsp;problem&nbsp;configuring&nbsp;the&nbsp;sshd&nbsp;service.\"\n}\n\nif&nbsp;(-Not&nbsp;$WhatIfOption)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;<em>#only&nbsp;display&nbsp;the&nbsp;summary&nbsp;if&nbsp;not&nbsp;using&nbsp;-WhatIf<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;$msg&nbsp;=&nbsp;@\"\nSSH&nbsp;setup&nbsp;complete.&nbsp;Edit&nbsp;$ENV:ProgramData\\ssh\\sshd_config&nbsp;for&nbsp;additional&nbsp;configurations&nbsp;options\nor&nbsp;to&nbsp;enable&nbsp;remoting&nbsp;under&nbsp;PowerShell&nbsp;7.\n\nYou&nbsp;will&nbsp;need&nbsp;to&nbsp;restart&nbsp;the&nbsp;sshd&nbsp;service&nbsp;for&nbsp;changes&nbsp;to&nbsp;take&nbsp;effect.\n\n\"@\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Host&nbsp;$msg&nbsp;-ForegroundColor&nbsp;green\n}\n\nWrite-Verbose&nbsp;\"Ending&nbsp;SSHD&nbsp;setup&nbsp;process.\"\n<\/code><\/pre>\n\n\n\n<p>The code is a bit different than what you would run interactively. When you run Invoke-Command and specify a file, PowerShell treats the contents of the file as a scriptblock and runs it in a remote runspace. That is why the parameters are not typical function parameters. I'm passing the Verbose and WhatIf preferences from the original command to the script.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Invoke-Command&nbsp;-FilePath&nbsp;.\\Setup-SSHServer.ps1&nbsp;-ComputerName&nbsp;win10&nbsp;-cred&nbsp;$artd&nbsp;-ArgumentList&nbsp;@(\"Continue\",&nbsp;$True)<\/code><\/pre>\n\n\n\n<p>This gives me  Verbose and Whatif output from the remote Windows 10 machine. Running the script with default values works just fine. If you want, you can add in the registry lines to set the default shell.  But ultimately I want to configure for PowerShell remoting over ssh so I don't need them.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PowerShell 7 SSH Remoting<\/h2>\n\n\n\n<p>There's one last step to configure remoting to use ssh and that happens on the remote machine. You need to edit the sshd_config file that is found in $env:ProgramData\\ssh. Here's my copy that has been edited with the necessary PowerShell requirements.<\/p>\n\n\n\n<pre title=\"sshd_config-default\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\"># This is the sshd server system-wide configuration file.  See\n# sshd_config(5) for more information.\n\n# The strategy used for options in the default sshd_config shipped with\n# OpenSSH is to specify options with their default value where\n# possible, but leave them commented.  Uncommented options override the\n# default value.\n\n#Port 22\n#AddressFamily any\n#ListenAddress 0.0.0.0\n#ListenAddress ::\n\n#HostKey __PROGRAMDATA__\/ssh\/ssh_host_rsa_key\n#HostKey __PROGRAMDATA__\/ssh\/ssh_host_dsa_key\n#HostKey __PROGRAMDATA__\/ssh\/ssh_host_ecdsa_key\n#HostKey __PROGRAMDATA__\/ssh\/ssh_host_ed25519_key\n\n# Ciphers and keying\n#RekeyLimit default none\n\n# Logging\n#SyslogFacility AUTH\n#LogLevel INFO\n\n# Authentication:\n\n#LoginGraceTime 2m\n#PermitRootLogin prohibit-password\n#StrictModes yes\n#MaxAuthTries 6\n#MaxSessions 10\n\n#ENABLED\nPubkeyAuthentication yes\n\n# The default is to check both .ssh\/authorized_keys and .ssh\/authorized_keys2\n# but this is overridden so installations will only check .ssh\/authorized_keys\nAuthorizedKeysFile\t.ssh\/authorized_keys\n\n#AuthorizedPrincipalsFile none\n\n# For this to work you will also need host keys in %programData%\/ssh\/ssh_known_hosts\n#HostbasedAuthentication no\n# Change to yes if you don't trust ~\/.ssh\/known_hosts for\n# HostbasedAuthentication\n#IgnoreUserKnownHosts no\n# Don't read the user's ~\/.rhosts and ~\/.shosts files\n#IgnoreRhosts yes\n\n# To disable tunneled clear text passwords, change to no here!\n# ENABLED: Set this to YES for PowerShell remoting\nPasswordAuthentication yes\n\n#PermitEmptyPasswords no\n\n#AllowAgentForwarding yes\n#AllowTcpForwarding yes\n#GatewayPorts no\n#PermitTTY yes\n#PrintMotd yes\n#PrintLastLog yes\n#TCPKeepAlive yes\n#UseLogin no\n#PermitUserEnvironment no\n#ClientAliveInterval 0\n#ClientAliveCountMax 3\n#UseDNS no\n#PidFile \/var\/run\/sshd.pid\n#MaxStartups 10:30:100\n#PermitTunnel no\n#ChrootDirectory none\n#VersionAddendum none\n\n# no default banner path\n#Banner none\n\n# override default of no subsystems\nSubsystem\tsftp\tsftp-server.exe\n#ADDED\nSubsystem     powershell c:\\progra~1\\powershell\\7\\pwsh.exe -sshs -NoLogo\n\n# Example of overriding settings on a per-user basis\n#Match User anoncvs\n#\tAllowTcpForwarding no\n#\tPermitTTY no\n#\tForceCommand cvs server\n\nMatch Group administrators\n       AuthorizedKeysFile __PROGRAMDATA__\/ssh\/administrators_authorized_keys<\/code><\/pre>\n\n\n\n<p>You might need additional changes depending on your organization. I can use PowerShell to copy this file to the remote computer, assuming OpenSSH.Server and PowerShell 7 have been installed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\">Copy-Item&nbsp;-Path&nbsp;.\\sshd_config_default&nbsp;-Destination&nbsp;$env:ProgramData\\ssh\\sshd_config&nbsp;-ToSession&nbsp;$sess<\/code><\/pre>\n\n\n\n<p>The sshd service should be restarted for the changes to take effect.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Deployment<\/h2>\n\n\n\n<p>The last step is to pull all of this together into a master control script. I decided to add code to also install PowerShell 7 using my <a href=\"https:\/\/github.com\/jdhitsolutions\/PSReleaseTools\" target=\"_blank\" rel=\"noreferrer noopener\">PSReleaseTools <\/a>module.<\/p>\n\n\n\n<pre title=\"Deploy-sshWin10.ps1\" class=\"wp-block-code\"><code lang=\"powershell\" class=\"language-powershell\"><em>#requires&nbsp;-version&nbsp;5.1<\/em>\n\n<em>#Deployment&nbsp;control&nbsp;script&nbsp;to&nbsp;setup&nbsp;SSH&nbsp;server&nbsp;on&nbsp;a&nbsp;remote&nbsp;Windows&nbsp;10&nbsp;desktop<\/em>\n<em>#It&nbsp;is&nbsp;assumed&nbsp;PowerShell&nbsp;7&nbsp;is,&nbsp;or&nbsp;will&nbsp;be,&nbsp;installed.<\/em>\n\n[cmdletbinding(<em>SupportsShouldProcess<\/em>)]\nParam(\n&nbsp;&nbsp;&nbsp;&nbsp;[Parameter(<em>Position<\/em>&nbsp;=&nbsp;0,&nbsp;<em>Mandatory<\/em>)]\n&nbsp;&nbsp;&nbsp;&nbsp;[string]$Computername,\n&nbsp;&nbsp;&nbsp;&nbsp;[pscredential]$Credential,\n&nbsp;&nbsp;&nbsp;&nbsp;[switch]$InstallPowerShell\n)\n\n<em>#remove&nbsp;parameters&nbsp;from&nbsp;PSBoundparameter&nbsp;that&nbsp;don't&nbsp;apply&nbsp;to&nbsp;New-PSSession<\/em>\nif&nbsp;($PSBoundParameters.ContainsKey(\"InstallPowerShell\"))&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;[void]($PSBoundParameters.remove(\"InstallPowerShell\"))\n}\n\nif&nbsp;($PSBoundParameters.ContainsKey(\"WhatIf\"))&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;[void]($PSBoundParameters.remove(\"WhatIf\"))\n}\n\n<em>#parameters&nbsp;for&nbsp;Write-Progress<\/em>\n$prog&nbsp;=&nbsp;@{\n&nbsp;&nbsp;&nbsp;&nbsp;Activity&nbsp;=&nbsp;\"Deploy&nbsp;SSH&nbsp;Server&nbsp;to&nbsp;Windows&nbsp;10\"\n&nbsp;&nbsp;&nbsp;&nbsp;Status&nbsp;=&nbsp;$Computername.toUpper()\n&nbsp;&nbsp;&nbsp;&nbsp;CurrentOperation&nbsp;=&nbsp;\"\"\n&nbsp;&nbsp;&nbsp;&nbsp;PercentComplete&nbsp;=&nbsp;0\n}\n<em>#create&nbsp;the&nbsp;PSSession<\/em>\nTry&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Creating&nbsp;a&nbsp;PSSession&nbsp;to&nbsp;$Computername\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.CurrentOperation&nbsp;=&nbsp;\"Creating&nbsp;a&nbsp;temporary&nbsp;PSSession\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.PercentComplete&nbsp;=&nbsp;10\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog\n&nbsp;&nbsp;&nbsp;&nbsp;$sess&nbsp;=&nbsp;New-PSSession&nbsp;@PSBoundParameters&nbsp;-ErrorAction&nbsp;Stop\n}\nCatch&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;Throw&nbsp;$_\n}\n\nif&nbsp;($sess)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($InstallPowerShell)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$prog.currentOperation&nbsp;=&nbsp;\"Installing&nbsp;PowerShell&nbsp;7\"\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$prog.percentComplete&nbsp;=&nbsp;25\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<em>#install&nbsp;PowerShell<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($pscmdlet.ShouldProcess($Computername.toUpper(),\"Install&nbsp;PowerShell&nbsp;7\"))&nbsp;{\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Invoke-Command&nbsp;-ScriptBlock&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[void](Install-PackageProvider&nbsp;-Name&nbsp;nuget&nbsp;-force&nbsp;-forcebootstrap)\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Install-Module&nbsp;PSReleaseTools&nbsp;-Force\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Install-PowerShell&nbsp;-EnableRemoting&nbsp;-EnableContextMenu&nbsp;-mode&nbsp;Quiet\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;-session&nbsp;$sess\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<em>#whatif<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;<em>#setup&nbsp;SSH<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.currentOperation&nbsp;=&nbsp;\"Installing&nbsp;OpenSSH&nbsp;Server\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.percentComplete&nbsp;=&nbsp;50\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog\n&nbsp;&nbsp;&nbsp;&nbsp;Invoke-Command&nbsp;-FilePath&nbsp;.\\Setup-SSHServer.ps1&nbsp;-Session&nbsp;$sess&nbsp;-ArgumentList&nbsp;@($VerbosePreference,&nbsp;$WhatIfPreference)\n\n&nbsp;&nbsp;&nbsp;&nbsp;<em>#copy&nbsp;the&nbsp;sshd_config&nbsp;file.&nbsp;This&nbsp;assumes&nbsp;you've&nbsp;installed&nbsp;PowerShell&nbsp;7&nbsp;on&nbsp;the&nbsp;remote&nbsp;computer<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Copying&nbsp;sshd_config&nbsp;to&nbsp;target\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.currentOperation&nbsp;=&nbsp;\"Copying&nbsp;default&nbsp;sshd_config&nbsp;to&nbsp;target\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.percentcomplete&nbsp;=&nbsp;60\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog\n&nbsp;&nbsp;&nbsp;&nbsp;Copy-Item&nbsp;-Path&nbsp;.\\sshd_config_default&nbsp;-Destination&nbsp;$env:ProgramData\\ssh\\sshd_config&nbsp;-ToSession&nbsp;$sess\n\n&nbsp;&nbsp;&nbsp;&nbsp;<em>#restart&nbsp;the&nbsp;service<\/em>\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Restarting&nbsp;the&nbsp;sshd&nbsp;service&nbsp;on&nbsp;the&nbsp;target\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.currentOperation&nbsp;=&nbsp;\"Restarting&nbsp;the&nbsp;ssh&nbsp;service&nbsp;target\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.percentComplete&nbsp;=&nbsp;75\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;($pscmdlet.ShouldProcess(\"sshd\",\"Restart&nbsp;service\"))&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Invoke-Command&nbsp;{&nbsp;Restart-Service&nbsp;-Name&nbsp;sshd&nbsp;}&nbsp;-Session&nbsp;$sess\n&nbsp;&nbsp;&nbsp;&nbsp;}\n\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Verbose&nbsp;\"Removing&nbsp;the&nbsp;temporary&nbsp;PSSession\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.currentOperation&nbsp;=&nbsp;\"Removing&nbsp;temporary&nbsp;PSSession\"\n&nbsp;&nbsp;&nbsp;&nbsp;$prog.percentComplete&nbsp;=&nbsp;90\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog\n&nbsp;&nbsp;&nbsp;&nbsp;$sess&nbsp;|&nbsp;Remove-PSSession\n\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Progress&nbsp;@prog&nbsp;-completed\n&nbsp;&nbsp;&nbsp;&nbsp;$msg&nbsp;=&nbsp;@\"\n\nSSH&nbsp;Server&nbsp;deployment&nbsp;complete&nbsp;for&nbsp;$($Computername.toUpper()).\n\nIf&nbsp;PowerShell&nbsp;7&nbsp;is&nbsp;installed&nbsp;remotely,&nbsp;you&nbsp;should&nbsp;be&nbsp;able&nbsp;to&nbsp;test\nwith&nbsp;an&nbsp;expression&nbsp;like:\n\nEnter-PSSession&nbsp;-hostname&nbsp;$Computername&nbsp;-username&nbsp;&lt;user&gt;&nbsp;-sshtransport\n\n\"@\n\n&nbsp;&nbsp;&nbsp;&nbsp;Write-Host&nbsp;$msg&nbsp;-ForegroundColor&nbsp;yellow\n}&nbsp;<em>#if&nbsp;$sess<\/em><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"607\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-1024x607.png\" alt=\"\" class=\"wp-image-7973\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-1024x607.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-300x178.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-768x455.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-1536x910.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-2048x1213.png 2048w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/install-powershell-850x504.png 850w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>I should probably add better error handling around configuring the sshd service but this should set up everything so that I can do this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><a href=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"328\" src=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh-1024x328.png\" alt=\"PowerShell remoting over ssh\" class=\"wp-image-7974\" srcset=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh-1024x328.png 1024w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh-300x96.png 300w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh-768x246.png 768w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh-1536x492.png 1536w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh-850x272.png 850w, https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/ps7-ssh.png 1930w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Next Steps<\/h2>\n\n\n\n<p>The next part of my Windows journey with ssh and PowerShell is to get my Windows servers configured. Once that is done, I can use PowerShell remoting over ssh for just about everything. I'll dive into this tomorrow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PowerShell 7 offers a number of compelling reasons to adopt it. One of the best is support for SSH as a PowerShell remoting protocol. Unfortunately, this is not a topic that typically comes up for Windows-centric IT Pros. I know this is definitely true in my case, and a deficiency I have been working on&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"New on the blog: Deploy OpenSSH Server to Windows 10 #PowerShell #PS7Now","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,610],"tags":[534,624,87,540,613],"class_list":["post-7969","post","type-post","status-publish","format-standard","hentry","category-powershell","category-powershell-7","tag-powershell","tag-ps7now","tag-remoting","tag-scripting","tag-ssh"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Deploy OpenSSH Server to Windows 10 &#8226; The Lonely Administrator<\/title>\n<meta name=\"description\" content=\"My experiences and PowerShell code for deploying OpenSSH.Server to Windows 10 over a traditional PowerShell remoting connection.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Deploy OpenSSH Server to Windows 10 &#8226; The Lonely Administrator\" \/>\n<meta property=\"og:description\" content=\"My experiences and PowerShell code for deploying OpenSSH.Server to Windows 10 over a traditional PowerShell remoting connection.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/\" \/>\n<meta property=\"og:site_name\" content=\"The Lonely Administrator\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-16T21:13:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-16T21:18:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1024x306.png\" \/>\n<meta name=\"author\" content=\"Jeffery Hicks\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:site\" content=\"@JeffHicks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jeffery Hicks\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/\"},\"author\":{\"name\":\"Jeffery Hicks\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"headline\":\"Deploy OpenSSH Server to Windows 10\",\"datePublished\":\"2020-12-16T21:13:23+00:00\",\"dateModified\":\"2020-12-16T21:18:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/\"},\"wordCount\":830,\"commentCount\":10,\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/sshserver-installed-1024x306.png\",\"keywords\":[\"PowerShell\",\"PS7Now\",\"remoting\",\"Scripting\",\"SSH\"],\"articleSection\":[\"PowerShell\",\"PowerShell 7\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/\",\"name\":\"Deploy OpenSSH Server to Windows 10 &#8226; The Lonely Administrator\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/sshserver-installed-1024x306.png\",\"datePublished\":\"2020-12-16T21:13:23+00:00\",\"dateModified\":\"2020-12-16T21:18:33+00:00\",\"description\":\"My experiences and PowerShell code for deploying OpenSSH.Server to Windows 10 over a traditional PowerShell remoting connection.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#primaryimage\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/sshserver-installed.png\",\"contentUrl\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/12\\\/sshserver-installed.png\",\"width\":1656,\"height\":495},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/powershell-7\\\/7969\\\/deploy-openssh-server-to-windows-10\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"PowerShell 7\",\"item\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/category\\\/powershell-7\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Deploy OpenSSH Server to Windows 10\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/\",\"name\":\"The Lonely Administrator\",\"description\":\"Practical Advice for the Automating IT Pro\",\"publisher\":{\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/jdhitsolutions.com\\\/blog\\\/#\\\/schema\\\/person\\\/d0258030b41f07fd745f4078bdf5b6c9\",\"name\":\"Jeffery Hicks\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\",\"caption\":\"Jeffery Hicks\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Deploy OpenSSH Server to Windows 10 &#8226; The Lonely Administrator","description":"My experiences and PowerShell code for deploying OpenSSH.Server to Windows 10 over a traditional PowerShell remoting connection.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/","og_locale":"en_US","og_type":"article","og_title":"Deploy OpenSSH Server to Windows 10 &#8226; The Lonely Administrator","og_description":"My experiences and PowerShell code for deploying OpenSSH.Server to Windows 10 over a traditional PowerShell remoting connection.","og_url":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/","og_site_name":"The Lonely Administrator","article_published_time":"2020-12-16T21:13:23+00:00","article_modified_time":"2020-12-16T21:18:33+00:00","og_image":[{"url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1024x306.png","type":"","width":"","height":""}],"author":"Jeffery Hicks","twitter_card":"summary_large_image","twitter_creator":"@JeffHicks","twitter_site":"@JeffHicks","twitter_misc":{"Written by":"Jeffery Hicks","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#article","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/"},"author":{"name":"Jeffery Hicks","@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"headline":"Deploy OpenSSH Server to Windows 10","datePublished":"2020-12-16T21:13:23+00:00","dateModified":"2020-12-16T21:18:33+00:00","mainEntityOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/"},"wordCount":830,"commentCount":10,"publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1024x306.png","keywords":["PowerShell","PS7Now","remoting","Scripting","SSH"],"articleSection":["PowerShell","PowerShell 7"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/","url":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/","name":"Deploy OpenSSH Server to Windows 10 &#8226; The Lonely Administrator","isPartOf":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#primaryimage"},"image":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#primaryimage"},"thumbnailUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed-1024x306.png","datePublished":"2020-12-16T21:13:23+00:00","dateModified":"2020-12-16T21:18:33+00:00","description":"My experiences and PowerShell code for deploying OpenSSH.Server to Windows 10 over a traditional PowerShell remoting connection.","breadcrumb":{"@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#primaryimage","url":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png","contentUrl":"https:\/\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/sshserver-installed.png","width":1656,"height":495},{"@type":"BreadcrumbList","@id":"https:\/\/jdhitsolutions.com\/blog\/powershell-7\/7969\/deploy-openssh-server-to-windows-10\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"PowerShell 7","item":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-7\/"},{"@type":"ListItem","position":2,"name":"Deploy OpenSSH Server to Windows 10"}]},{"@type":"WebSite","@id":"https:\/\/jdhitsolutions.com\/blog\/#website","url":"https:\/\/jdhitsolutions.com\/blog\/","name":"The Lonely Administrator","description":"Practical Advice for the Automating IT Pro","publisher":{"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jdhitsolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/jdhitsolutions.com\/blog\/#\/schema\/person\/d0258030b41f07fd745f4078bdf5b6c9","name":"Jeffery Hicks","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg","caption":"Jeffery Hicks"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/832ae5d438fdcfc1420d720cd1991307927de8a0b12f2342e81c30f773e21098?s=96&d=wavatar&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":7978,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7978\/deploy-openssh-to-windows-server\/","url_meta":{"origin":7969,"position":0},"title":"Deploy OpenSSH to Windows Server","author":"Jeffery Hicks","date":"December 17, 2020","format":false,"excerpt":"Yesterday I shared some PowerShell ideas for remotely setting up the server component of ssh on a remote Windows 10 system. This would allow you to establish an ssh session to the desktop or even use PowerShell remoting over ssh. Next, we need to look at doing the same thing\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2020\/12\/win2019-psssh.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":5895,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/5895\/another-look-at-powershell-core-version-information\/","url_meta":{"origin":7969,"position":1},"title":"Another Look at PowerShell Core Version Information","author":"Jeffery Hicks","date":"February 8, 2018","format":false,"excerpt":"As PowerShell Core begins to spread into our world, and as we start thinking about working and scripting cross-platform, it will be useful to know what type of platform you are running on. The built in $PSVersionTable is an obvious place to start. On PowerShell Core there are also some\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-5.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-5.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2018\/02\/image_thumb-5.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":7257,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/7257\/cross-platform-powershell-profiles-with-windows-terminal\/","url_meta":{"origin":7969,"position":2},"title":"Cross Platform PowerShell Profiles with Windows Terminal","author":"Jeffery Hicks","date":"February 13, 2020","format":false,"excerpt":"Earlier this week I shared my techniques for creating a Windows Terminal profile that would open a remote PowerShell session. But with PowerShell 7, I can also connect to non-Windows machines using SSH. So why not extend my code to allow connecting to a Linux box? Before you try anything\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8492,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8492\/searching-for-powershell-with-cim\/","url_meta":{"origin":7969,"position":3},"title":"Searching for PowerShell with CIM","author":"Jeffery Hicks","date":"July 15, 2021","format":false,"excerpt":"Yesterday I shared a script that you could use to inventory systems for Windows PowerShell and PowerShell 7 installations. This should work for most people who install PowerShell 7 with the provided installer. But, as has been pointed out more than once to me, this won't detect any side-loaded or\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/pwsh-cim3.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":8499,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell\/8499\/using-the-powershell-ise-as-a-remote-management-console\/","url_meta":{"origin":7969,"position":4},"title":"Using the PowerShell ISE as a Remote Management Console","author":"Jeffery Hicks","date":"July 20, 2021","format":false,"excerpt":"Way back before the days of PowerShell Core, or even VS Code for that matter, the PowerShell ISE was the center of my PowerShell world. I spent a lot of time finding ways to make it easier for me to use and to push it to its limits. Naturally, the\u2026","rel":"","context":"In &quot;PowerShell&quot;","block_context":{"text":"PowerShell","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/jdhitsolutions.com\/blog\/wp-content\/uploads\/2021\/07\/ise-remotetab-form2.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":610,"url":"https:\/\/jdhitsolutions.com\/blog\/powershell-v2-0\/610\/powershell-quick-start-on-server-core-r2\/","url_meta":{"origin":7969,"position":5},"title":"PowerShell Quick Start on Server Core R2","author":"Jeffery Hicks","date":"March 29, 2010","format":false,"excerpt":"The great thing about the Server Core flavor that ships with Windows Server 2008 R2 is that it finally supports Windows PowerShell. I\u2019ve talked about this before. However, I think I neglected some of the finer points in getting started. You can (and should) run PowerShell on your R2 Core\u2026","rel":"","context":"In &quot;PowerShell v2.0&quot;","block_context":{"text":"PowerShell v2.0","link":"https:\/\/jdhitsolutions.com\/blog\/category\/powershell-v2-0\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7969","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=7969"}],"version-history":[{"count":0,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/7969\/revisions"}],"wp:attachment":[{"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=7969"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=7969"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jdhitsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=7969"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}