桌面 CLI
DR-Terminal 的桌面版本附带一个命令行界面。对于 IDE 集成、脚本编写和自动化很有用。
用法
DR-Terminal connect <target> [flags]
- target — 先作为已保存连接名称解析(不区分大小写),然后按
host[:port]与已保存的连接匹配(给出-u时会进一步收窄),最后才解析为host[:port]以建立临时会话。命中已保存连接时会复用该连接的主题、分组和已存储的凭据。
标志
| 标志 | 说明 |
|---|---|
-u, --user | 用户名(用于 host:port 目标)。 |
-p, --password | 命令行上的密码(不安全 — 可能进入 shell 历史)。 |
--password-stdin | 从标准输入读取密码(安全:pass show server | DR-Terminal ...)。仅适用于 --exec。 |
-i, --identity | 私钥文件(PEM)。仅适用于 --exec。 |
-j, --jump | 按名称指定的跳板机链,例如 bastion1,bastion2。 |
-c, --command | Shell 代码片段:在登录后注入(默认)或使用 --exec 无界面执行。 |
--new-tab | 强制在运行中的实例里打开一个新标签页。 |
--exec | 无界面:运行命令,流式输出 stdout/stderr,并以远程退出码退出。 |
-h, --help | 显示此帮助。 |
-i 和 --password-stdin 仅适用于无界面的 --exec 运行。在 GUI 中打开标签页时,认证使用已保存连接的凭据或常规的应用内提示。
示例
# Open a new tab in the running instance and log into saved "lager"
DR-Terminal connect lager --new-tab
# Ad-hoc host with user — the app prompts for credentials
DR-Terminal connect 10.0.0.1:22 -u pi --new-tab
# Jump chain: bastion1 → bastion2 → target
DR-Terminal connect production -j bastion1,bastion2 --new-tab
# Headless exec with a key file — prints uptime and exits
DR-Terminal connect 10.0.0.1:22 -u pi -i ~/.ssh/id_ed25519 --exec -c 'uptime'
# CLI start script: run commands after login
DR-Terminal connect dev --new-tab -c 'cd /srv/app && tmux attach -t main'
符号链接到 PATH
安装 DR-Terminal 后,创建一个符号链接,使该命令可全局使用:
sudo ln -s /path/to/DR-Terminal/bin/DR-Terminal /usr/local/bin/dr-terminal
dr-terminal connect lager --exec -c 'df -h'
单实例
DR-Terminal 为每个用户保持单个实例(Unix 域套接字,或 Windows 上的命名管道)。第二个 DR-Terminal connect ... 会把它的参数转发给运行中的实例并退出 — 运行中的实例随后打开一个新标签页。