无法在Windows服务器上通过SSH会话与Plink执行命令

问题描述:

我正尝试使用Plink在远程服务器上运行命令。两者,本地&远程机器都是Windows。虽然我能够使用Plink连接到远程机器,但我无法使用'-m文件'选项。我尝试了以下三种方法,但无济于事:无法在Windows服务器上通过SSH会话与Plink执行命令

尝试1:

plink.exe -ssh -pw mypwd [email protected] -m file.txt 

输出:

Could not chdir to home directory /home/gchhabra: No such file or directory 
dir: not found 

'file.txt的' 只包含一个命令即DIR

尝试2:

plink.exe -ssh -pw mypwd [email protected] dir 

输出:

Could not chdir to home directory /home/gchhabra: No such file or directory 
dir: not found 

尝试3:

plink.exe -ssh -pw mypwd [email protected] < file.txt 

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

Using username "gchhabra". 

          ****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/gchhabra: No such file or directory 
Microsoft Windows [Version x.x.xxx] 
(C) Copyright 1985-2003 Microsoft Corp. 

C:\Program Files\OpenSSH> 

后我得到上面的状态下,则挂起。在这方面有什么帮助?

这是现在的工作。

plink -ssh -pw xxx [email protected] cmd.exe /c move c://sample//gc//file.txt c://test//

好像plink -m工作正常:从file.txt的命令被发送到服务器。

然而,你的SSH服务器运行一个shell(可能bash因为OpenSSH的用于Windows使用Cygwin的)不理解你正在使用,像movedir的命令。因为bash实现了它们自己版本的这些命令(分别为mvls)。正如您发现的那样,您需要运行cmd.exe /C以脱离SSH服务器的Windows目录,以正确解释命令的含义。另一种选择是直接使用bash版本的命令。

您在Windows服务器上使用Cygwin上的OpenSSH。

Cygwin模拟Windows上的Unix环境。

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

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

而且,你的服务器似乎错误地配置


Could not chdir to home directory /home/gchhabra: No such file or directory 

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