具有多个命令的 Linux SSH

标签 linux ssh command

<分区>

我想通过 ssh 连接到远程主机,在那里我想运行多个命令。

ssh -l blabla 123.123.123.123 ls -l

当我运行它时,我将在 123.123...上得到 ls -l 的结果

有没有可能,做这样的事情:

ssh -l blabla 123.123.123.123 ls -l & ifconfig

...它试过这个:

ssh -l blabla 123.123.123.123 ls -l; ifconfig

但是本地 bash 运行第二个命令。 我希望第二个命令在远程主机上运行。

谢谢!

最佳答案

只需将所有命令放在引号内

ssh afont@123.123.123.123 "ls -l; ifconfig;"

关于具有多个命令的 Linux SSH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38075655/

相关文章:

c - 为什么我的消息传递 IPC 代码不起作用? (C)

linux - 将函数命名为环境命令

c# - 如何确定文件是否在 SSH.NET 中完成下载

ssh - 计算 ecdsa-sha2-nistp256 的交换哈希

java - 从命令行运行 Java 程序

java - 从 Java 运行 Linux 命令 - runtime.exe

java - 使用 getClassLoader().getResource 时 Linux 机器上的 FileNotFoundException

r - rgdal "gdal-config"配置错误

linux - 如何将私钥作为文本传递给 ssh?

windows - 在多个 Windows 服务器上运行命令