是否可以更改用于通过SSH登录的终端类型?


8

当我通过SSH(没有管理员访问权限)登录某个特定的服务器时,出现以下错误:(urxvt-unicode: Unknown terminal type我也不想永久更改终端类型)。这很重要,因为根据终端类型,登录时我会得到不同的颜色。

是否可以仅在通过SSH登录时更改终端类型?

Answers:


7

如果您具有root用户权限,请安装该软件包ncurses-term。这将提供rxvt-256colorterminfo条目。

作为非root用户,您还可以将rxvt terminfo条目复制到 $HOME/.terminfo/r/远程计算机上,然后导出TERMINFO=$HOME/.terminfo

ssh <host> 'mkdir -p .terminfo/r'
scp /usr/share/terminfo/r/rxvt-unicode-256color <host>:~/.terminfo/r/

我什么都没有/usr/share/terminfo/
Ondra参观Žižka


2

sshd进程(来自sshd(8))将读取...

6.   Reads the file ~/.ssh/environment, if it exists, and users are
allowed to change their environment.  See the PermitUserEnvironment 
option in sshd_config(5).

8.   If ~/.ssh/rc exists, runs it; else if /etc/ssh/sshrc exists, 
runs it; otherwise runs xauth.  The “rc” files are given the X11 
authentication protocol and cookie in standard input.  See SSHRC, below.

您可能希望编辑~/.ssh/rc以设置TERM的值,因为此文件是在Shell的配置文件之前读取的。


1

通常TERM是从本地环境(不变)传递到远程环境。如果您TERM在调用时在本地进行设置ssh,则将完成所需的操作。

例如,如果远端具有rxvt(但没有rxvt-unicode)的终端说明,那么对于功能键等来说就足够了。

假设bash或某些符合POSIX的shell,您可以通过以下方式执行此操作

TERM=rxvt ssh 远程主机

这样做只会影响ssh命令,而不会影响您的本地环境。我使用此功能来处理没有描述的典型机器screen.xterm-new。根据远程计算机的不同,可能会或可能不会为整个终端数据库安装合适的软件包。有些(例如Solaris和FreeBSD)需要解决方法。

进一步阅读:

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.