我可以更改通过 SSH 登录的终端类型吗?

我可以更改通过 SSH 登录的终端类型吗?

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

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

答案1

如果您具有远程设备的 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/

答案2

您还可以将以下行添加到 .ssh/config 中:

host *
   SetEnv TERM=xterm

或者您喜欢的任何终端。

您也可以为每个主机设置

host foo.bar
   SetEnv TERM=vt100

答案3

登录后您可以执行如下操作:

export TERM=vt100

答案4

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 的配置文件之前读取的。

相关内容