我想根据 ssh 连接的 HOSTNAME 更改我的终端颜色。
我知道如何修改终端,但如何使用 ssh 来添加钩子?
我可以用 shell 函数包装 ssh 命令,或者替换二进制文件,但它被其他应用程序用作依赖项,我宁愿不这样做。
您可以在连接到远程服务器时使用的LocalCommand功能OpenSSH:
LocalCommand
Specifies a command to execute on the local machine after successfully connecting to the server. The command string extends to the end of the line, and is executed
with the user's shell. The following escape character substitutions will be performed: ‘%d’ (local user's home directory), ‘%h’ (remote host name), ‘%l’ (local host
name), ‘%n’ (host name as provided on the command line), ‘%p’ (remote port), ‘%r’ (remote user name) or ‘%u’ (local user name).
The command is run synchronously and does not have access to the session of the ssh(1) that spawned it. It should not be used for interactive commands.
This directive is ignored unless PermitLocalCommand has been enabled.
Run Code Online (Sandbox Code Playgroud)
除了编写ssh包装器之外,在结束与远程服务器的连接时可能没有简单的方法来执行命令。
| 归档时间: |
|
| 查看次数: |
1430 次 |
| 最近记录: |