简体   繁体   English

如何从 Linux 终端在远程主机上运行命令

[英]How to run a command on a remote host from a Linux terminal

The situation is like this:情况是这样的:

There's a public shared folder containing command file on a remote server saying ServerRemoteA.远程服务器上有一个包含命令文件的公共共享文件夹,名为 ServerRemoteA。 From my laptop's Win10 cmd terminal I can run \\ServerRemoteA\sharedfolder\Windows\SomeCommand.exe successfully.从我笔记本电脑的 Win10 cmd 终端我可以成功运行 \\ServerRemoteA\sharedfolder\Windows\SomeCommand.exe。

Now I ssh-logged to another LinuxHost and I should run its Linux version sharedfolder/Linux/SomeCommand on the same host ServerRemoteA, from the Linux terminal现在我 ssh 登录到另一个 LinuxHost,我应该从 Linux 终端在同一主机 ServerRemoteA 上运行其 Linux 版本 sharedfolder/Linux/SomeCommand

I was refused to use "ssh user@host "command" " by the server.我被服务器拒绝使用 "ssh user@host "command" "。 But I can run the exe version from Windows machine.但我可以从 Windows 机器上运行 exe 版本。

How can I do?我能怎么做?

If you are connected to a remote host the program will run in the remote host, so the client does not matter if it is Linux or Windows.如果您连接到远程主机,程序将在远程主机中运行,因此客户端是 Linux 还是 Windows 无关紧要。 Thus, If you connect from:因此,如果您从以下位置连接:

Linux/Windows -> Windows: \\ServerRemoteA\sharedfolder\Windows\SomeCommand.exe
Linux/Windows -> Linux: sharedfolder/Linux/SomeCommand

if the SSH is in Linux if you just want to run one command you can use the following command:如果 SSH 位于 Linux 如果您只想运行一个命令,则可以使用以下命令:

ssh -l <username> ServerRemoteA "sharedfolder/Linux/SomeCommand"

Or if the server is in Windows from Linux ssh client:或者,如果服务器位于 Linux ssh 客户端的 Windows 中:

ssh -l <username> ServerRemoteA "C:\\sharedfolder\Windows\SomeCommand.exe"

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

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