简体   繁体   English

从 Linux 到 Windows 的 scp:'C:\\Program' 无法识别错误

[英]scp from Linux to Windows: 'C:\Program' is not recognized error

In my linux machine, I'm trying to send a file over to a Windows machine via:在我的 linux 机器中,我试图通过以下方式将文件发送到 Windows 机器:

scp fileNameA user@windowServer:fileNameA 

I get the following message:我收到以下消息:

'C:\Program' is not recognized as an internal or external command,

operable program or batch file.可运行的程序或批处理文件。

What's prompting this message?是什么提示这个消息?

I've installed OpenSSH on the windows machine, and I can successfully SSH into it.我已经在 windows 机器上安装了 OpenSSH,我可以成功地通过 SSH 进入它。 I don't want to use WinSCP, FileZilla, etc, because I have to automate this in a script.我不想使用 WinSCP、FileZilla 等,因为我必须在脚本中自动执行此操作。 This has to be done from the Linux machine, so I'm not interested in doing pscp from the Windows machine.这必须在 Linux 机器上完成,所以我对从 Windows 机器上执行 pscp 不感兴趣。

I have met the same problem today.我今天遇到了同样的问题。

I think it is an issue in the new version of OpenSSH, which was published few days ago.我认为这是几天前发布的新版本 OpenSSH 中的一个问题。 I reverted previous version (v7.6.1.0p1-Beta), which was working correctly on my VM from https://github.com/PowerShell/Win32-OpenSSH/releases and problem was fixed without any changes in configuration.我从https://github.com/PowerShell/Win32-OpenSSH/releases恢复了以前的版本 (v7.6.1.0p1-Beta),该版本在我的 VM 上正常工作,问题得到解决,配置没有任何更改。

I just fixed the same problem by moving my installation of OpenSSH from C:\\Program Files\\OpenSSH to C:\\OpenSSH .我只是通过将我的 OpenSSH 安装从C:\\Program Files\\OpenSSHC:\\OpenSSH来解决同样的问题。

I had to first uninstall it properly using the provided script in Win32-OpenSSH and then follow back the information provided there https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH but only changing the path to C:\\OpenSSH.我必须首先使用 Win32-OpenSSH 中提供的脚本正确卸载它,然后按照https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH 中提供的信息返回,但只将路径更改为C:\\OpenSSH。

I met a similar issue today, trying to copy files to a Windows server running OpenSSH-Win64 .我今天遇到了类似的问题,试图将文件复制到运行OpenSSH-Win64的 Windows 服务器。 I solved the problem by adding C:\\Program Files\\OpenSSH , which is the recommended installation location, to the Windows path:我通过将C:\\Program Files\\OpenSSH (推荐的安装位置)添加到 Windows 路径解决了该问题:

  1. Open the Control Panel , go to the System and Security section and open up System .打开控制面板,转到系统和安全部分并打开系统
  2. Click on Advanced System Settings and, in the System Properties dialog box, click Environmental Variables .单击高级系统设置,然后在系统属性对话框中单击环境变量
  3. In the System Variables section of the dialog box, select Path and click Edit... .在对话框的System Variables部分,选择Path并单击Edit...
  4. Click New , add the OpenSSH folder path and click OK to apply the change.单击New ,添加 OpenSSH 文件夹路径,然后单击OK应用更改。

Then, do not forget to restart the OpenSSH service, either in the service management console or by running net stop sshd , followed by net start sshd in an elevated console.然后,不要忘记在服务管理控制台中或通过运行net stop sshd ,然后在提升的控制台中运行net start sshd重新启动 OpenSSH 服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM