Linux 使用多个命令的 SSH

Linux SSH with multiple commands

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

ssh -l blabla 123.123.123.123 ls -l

当我运行这个的时候,我会得到ls -l on 123.123...

的结果

有没有可能,做成这样:

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;"

您应该尝试在命令前使用“-t”:

ssh UserName@HostNameOrIP -t 'comand1 && command2'