无法使用Plink通过SSH会话在Windows server上执行命令

无法使用Plink通过SSH会话在Windows server上执行命令,ssh,plink,Ssh,Plink,我正在尝试使用Plink在远程服务器上运行命令。本地和远程计算机都是Windows。虽然我可以使用Plink连接到远程机器,但我不能使用'-m file'选项。我尝试了以下三种方法,但都没有成功: 尝试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 fou

我正在尝试使用Plink在远程服务器上运行命令。本地和远程计算机都是Windows。虽然我可以使用Plink连接到远程机器,但我不能使用'-m file'选项。我尝试了以下三种方法,但都没有成功:

尝试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
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
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
在我得到上面的提示后,它将挂起。在这方面有什么帮助吗?

现在可以了

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

现在可以使用了


plink-ssh-pw-xxx-john。doe@servercmd.exe/c move c://sample//jd//file.txt c://test//
看起来
plink-m
工作正常:file.txt中的命令正在发送到服务器


但是,您的SSH服务器运行的shell(可能是
bash
,因为OpenSSH for Windows使用Cygwin)不理解您正在使用的命令,例如
move
dir
。因为
bash
实现了这些命令的自己版本(
mv
ls
)。正如您所发现的,您需要在Windows目录外运行
cmd.exe/C
,SSH服务器才能正确解释命令的含义。另一个选项是直接使用命令的
bash
版本。

看起来
plink-m
工作正常:file.txt中的命令正在发送到服务器


但是,您的SSH服务器运行的shell(可能是
bash
,因为OpenSSH for Windows使用Cygwin)不理解您正在使用的命令,例如
move
dir
。因为
bash
实现了这些命令的自己版本(
mv
ls
)。正如您所发现的,您需要在Windows目录外运行
cmd.exe/C
,SSH服务器才能正确解释命令的含义。另一个选项是直接使用命令的
bash
版本。

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

Cygwin在Windows上模拟Unix环境

因此,您必须使用Unix,而不是Windows命令(例如
mv
not
move
rename

而且您需要使用类似Unix的路径,而不是Windows路径(特别是前斜杠)

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


无法chdir到主目录/home/john.doe:没有这样的文件或目录


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

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

Cygwin在Windows上模拟Unix环境

因此,您必须使用Unix,而不是Windows命令(例如
mv
not
move
rename

而且您需要使用类似Unix的路径,而不是Windows路径(特别是前斜杠)

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


无法chdir到主目录/home/john.doe:没有这样的文件或目录

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