【问题标题】:Cannot execute commands on Windows server over SSH session with Plink无法通过与 Plink 的 SSH 会话在 Windows 服务器上执行命令
【发布时间】:2010-06-08 07:25:06
【问题描述】:

我正在尝试使用 Plink 在远程服务器上运行命令。本地和远程机器都是 Windows。虽然我可以使用 Plink 连接到远程机器,但我无法使用“-m 文件”选项。我尝试了以下三种方法,但均无济于事:

尝试1:

plink.exe -ssh -pw mypwd john.doe@server -m file.txt

输出:

Could not chdir to home directory /home/john.doe: No such file or directory
dir: not found

'file.txt' 只包含一个命令,即 dir

尝试2:

plink.exe -ssh -pw mypwd john.doe@server dir

输出:

Could not chdir to home directory /home/john.doe: No such file or directory
dir: not found

尝试 3:

plink.exe -ssh -pw mypwd john.doe@server < file.txt

在这种情况下,我得到以下输出:

Using username "john.doe".

                            ****USAGE WARNING****

This is a private computer system. This computer system, including all
..... including personal information, placed or sent over this system
may be monitored.

Use of this computer system, authorized or unauthorized, constitutes consent
... constitutes consent to monitoring for these purposes.


dirCould not chdir to home directory /home/john.doe: No such file or directory
Microsoft Windows [Version x.x.xxx]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Program Files\OpenSSH>  

收到上述提示后,它挂起。有这方面的帮助吗?

【问题讨论】:

    标签: ssh plink


    【解决方案1】:

    plink -m 似乎工作正常:来自 file.txt 的命令正在发送到服务器。

    但是,您的 SSH 服务器运行的 shell(可能是 bash,因为 Windows 的 OpenSSH 使用 Cygwin)不理解您正在使用的命令,例如 movedir。因为bash 实现了自己的这些命令版本(分别为mvls)。正如您所发现的,您需要在 Windows 目录之外运行cmd.exe /C,以便您的 SSH 服务器正确解释您的命令的含义。另一种选择是直接使用bash 版本的命令。

    【讨论】:

      【解决方案2】:

      现在可以了。

      plink -ssh -pw xxx john.doe@server cmd.exe /c move c://sample//jd//file.txt c://test//

      【讨论】:

        【解决方案3】:

        您正在 Windows 服务器上通过 Cygwin 使用 OpenSSH。

        Cygwin 在 Windows 上模拟 Unix 环境。

        所以你必须使用 Unix,而不是 Windows 命令(例如 mv 而不是 moverename

        您需要使用类 Unix 路径,而不是 Windows 路径(尤其是正斜杠)。

        此外,您的服务器似乎配置错​​误。


        Could not chdir to home directory /home/john.doe: 没有这样的文件或目录

        这可能是一个错误配置的帐户。该错误与您正在执行的命令无关。

        【讨论】:

          猜你喜欢
          • 2013-11-22
          • 2019-01-09
          • 1970-01-01
          • 1970-01-01
          • 2018-07-31
          • 1970-01-01
          • 2013-09-05
          • 1970-01-01
          • 2020-10-30
          相关资源
          最近更新 更多