vic*_*vic 17 ssh powershell openssh windows-10
我遇到了内置 OpenSSH 客户端的某些问题,根据Win32-OpenSSH Github页面,这些问题似乎在较新版本中已解决。最新版本是 v7.9,而预装的客户端版本是 7.6p1。
PS C:\> ssh -V
OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4
Run Code Online (Sandbox Code Playgroud)
我知道可以在“应用程序和功能”设置页面中将 OpenSSH 作为可选功能安装,也可以使用 Powershell。在我的情况下,这似乎是徒劳的,因为显然已经安装了客户端。
PS C:\> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Run Code Online (Sandbox Code Playgroud)
不幸的是,似乎不可能以这种方式更新客户端,而且 Github 页面似乎没有发布二进制文件。这是否意味着如果我想使用更新的版本,我必须自己制作二进制文件,它们甚至可以作为未签名的替代品或其他任何东西吗?也许有更简单的方法?
ᄂ ᄀ*_*ᄂ ᄀ 14
Remove-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Run Code Online (Sandbox Code Playgroud)
winget install openssh-beta
Run Code Online (Sandbox Code Playgroud)
[Environment]::SetEnvironmentVariable("Path",
$env:Path + ';' + ${Env:ProgramFiles} + '\OpenSSH',
[System.EnvironmentVariableTarget]::Machine)
Run Code Online (Sandbox Code Playgroud)
Red*_*dio 12
此页面提供了使用 Powershell 安装最新软件包的步骤。
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/latest/'
$request = [System.Net.WebRequest]::Create($url)
$request.AllowAutoRedirect=$false
$response=$request.GetResponse()
$([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/OpenSSH-Win64.zip'
$([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/OpenSSH-Win32.zip'
Run Code Online (Sandbox Code Playgroud)
如果你使用的巧克力,然后键入以下命令提示符如图所示在这里:
choco upgrade openssh
Run Code Online (Sandbox Code Playgroud)
覆盖文件的答案有效:
下载最新版本并在 C:\Windows\System32 中更新它们。
然而,这说起来容易做起来难,因为 Windows 如何限制在 System32 中修改/写入文件的权限。以管理员身份运行 PowerShell 不足以修改文件。我必须更改所有权并添加完全控制权限才能完成如下操作:
# Download upstream bins
$url = 'https://github.com/PowerShell/Win32-OpenSSH/releases/latest/'
$request = [System.Net.WebRequest]::Create($url)
$request.AllowAutoRedirect=$false
$response=$request.GetResponse()
$source = $([String]$response.GetResponseHeader("Location")).Replace('tag','download') + '/OpenSSH-Win64.zip'
(New-Object System.Net.WebClient).DownloadFile($source, 'OpenSSH-Win64.zip')
# Overwrite windows installed bins
$openSshBins = (Get-ChildItem 'C:\WINDOWS\System32\OpenSSH\').Name
Expand-Archive -Path .\OpenSSH-Win64.zip -DestinationPath .
takeown.exe /a /r /f C:\Windows\System32\OpenSSH\
icacls.exe 'C:\Windows\System32\OpenSSH' /grant 'BUILTIN\Administrators:(OI)(CI)F'
icacls.exe 'C:\Windows\System32\OpenSSH' /grant 'BUILTIN\Administrators:F' /t
Stop-Service ssh-agent
$openSshBins | %{ Copy-Item -Path .\OpenSSH-Win64\$_ -Destination C:\Windows\System32\OpenSSH\ }
Start-Service ssh-agent
Run Code Online (Sandbox Code Playgroud)
请注意,要自动下载,您需要允许重定向。
| 归档时间: |
|
| 查看次数: |
19502 次 |
| 最近记录: |