通过单个命令通过 ssh 运行 htop

wb7*_*wb7 19 linux ssh maintenance htop

我想通过 ssh 运行 htop - 但是在带有 shell 脚本的无键盘系统上自动启动它。我的第一个想法是

ssh user@test.home 'htop'
Run Code Online (Sandbox Code Playgroud)

但:

Error opening terminal: unknown.
Run Code Online (Sandbox Code Playgroud)

有没有办法在不每次连接时都输入命令的情况下启动 htop remote?

提前致谢!

mta*_*tak 23

-tSSH 中使用该标志:

ssh user@test.home -t 'htop'
Run Code Online (Sandbox Code Playgroud)

这将强制进行 TTY 分配(如果没有必要,ssh 不会分配 TTY,通常仅用于交互式 shell)。