我正在使用powershell将密钥添加到windows 7 x64
到目前为止,我已经使用powershell尝试了以下命令
powershell -executionpolicy bypass -file install-sshed.ps1
我得到的错误如下:
将参数‘
-sshed.ps1’安装到-File参数不存在。提供现有“”.ps1“”文件的路径作为-File参数的参数
我做错了什么?
发布于 2019-03-24 22:50:17
您的PowerShell会话似乎是在与PowerShell脚本不同的文件夹中启动的。尝试将完整路径添加到PowerShell脚本:
powershell -executionpolicy bypass -file "c:\scripts\install-sshed.ps1"
或者,先切换到*.ps1
文件所在的目录:
cd c:\scripts
powershell -executionpolicy bypass -file install-sshed.ps1
发布于 2019-03-25 01:28:09
除了上面的答案,我想补充的是,你也可以使用相对路径。
例如,从当前目录运行
powershell -execution policy unrestricted -file ".\test.ps1"
或者从嵌套文件夹运行:
powershell -execution policy unrestricted -file ".\config\test.ps1"
我还建议添加以下参数:-noprofile
这将确保不会加载任何用户配置文件,这是运行脚本时的最佳实践。你可以找到一个有趣的阅读here
发布于 2019-07-21 02:06:33
除了其他答案之外。
您可能已经下载了OpenSSH-Win32_Symbols.zip
或OpenSSH-Win64_Symbols.zip
-这些都不是必需的二进制文件。您可以尝试分别下载OpenSSH-Win32.zip
或OpenSSH-Win64.zip
版本。
此外,它还建议您应该cd
到C:\Program Files\OpenSSH
,但归档在一个子文件夹中,我必须将其解压缩到父OpenSSH文件夹中。
Extra: asterikx描述的here权限的常见问题,如果某些东西不能正常工作,您可能会发现按照以下步骤重新安装openssh很有用(假设下载的归档位于openssh):
powershell.exe -ExecutionPolicy Bypass -File 'C:\Program Files\OpenSSH\uninstall-sshd.ps1'
del 'C:\Program Files\OpenSSH\'
Expand-Archive D:\Downloads\OpenSSH-Win64.zip -DestinationPath 'C:\Program Files\OpenSSH'
copy 'C:\Program Files\OpenSSH\OpenSSH-Win64\*' 'C:\Program Files\OpenSSH\'
del 'C:\Program Files\OpenSSH\OpenSSH-Win64\'
powershell.exe -ExecutionPolicy Bypass -File 'C:\Program Files\OpenSSH\install-sshd.ps1'
powershell.exe -ExecutionPolicy Bypass -File 'C:\Program Files\OpenSSH\install-sshd.ps1'
powershell.exe -ExecutionPolicy Bypass -File 'C:\Program Files\OpenSSH\FixHostFilePermissions.ps1'
powershell.exe -ExecutionPolicy Bypass -File 'C:\Program Files\OpenSSH\FixUserFilePermissions.ps1'
Set-Service sshd -StartupType Automatic
Set-Service ssh-agent -StartupType Automatic
https://stackoverflow.com/questions/55324936
复制相似问题