我怎样才能通过 ssh 浏览一下?

mik*_*e23 0 ssh remote terminal

我在远程服务器上安装了Glances,现在我尝试从本地计算机连接到它并运行它,如下所示:

ssh user@host glances
Run Code Online (Sandbox Code Playgroud)

这给了我以下错误:

Traceback (most recent call last):

File "/usr/bin/glances", line 9, in <module>
load_entry_point('Glances==1.7.3', 'console_scripts', 'glances')()

File "/usr/lib/python2.7/dist-packages/glances/glances.py", line 4644, in main
use_bold=use_bold)

File "/usr/lib/python2.7/dist-packages/glances/glances.py", line 1937, in __init__
self.screen = curses.initscr()

File "/usr/lib/python2.7/curses/__init__.py", line 33, in initscr
fd=_sys.__stdout__.fileno())

_curses.error: setupterm: could not find terminal
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

Jef*_*ler 6

由于您给出了一个用于ssh远程运行的命令,ssh 没有分配一个伪终端供浏览器使用。只需将-t选项添加到 ssh 即可强制执行:

ssh -t user@host glances
Run Code Online (Sandbox Code Playgroud)

参考:

ssh 手册页

当用户的身份被服务器接受后,服务器要么在非交互式会话中执行给定的命令

...

如果请求交互式会话,默认情况下 ssh 只会在客户端有一个交互式会话时请求一个伪终端 (pty)。标志 -T 和 -t 可用于覆盖此行为。