你的情况你没说清楚,我就说说我以前的搞法吧。
我在跳板机上写了一个定制版的 ssh client,
我的功能比较多,其中就包含下面部分,你可以根据这个原理自行封装一个简单的脚本
1,ssh 的目标设备信息(IP、账号、证书、密码等等)存在数据库中通过 API 可以查询
2,使用的时候,myssh host1 就可以自动从 API 中加载 host1 相关的登录信息(跟当前用户有关)
3,myssh 设置窗口标题为 host1
4,myssh 根据 host1 的登录信息,开始 ssh host1
这样问题不就解决了?而且并不要求 host1 的 PS1 配合,PS1 设置成什么样子都可以。
如果你的跳板机上不能写这么一个程序,那上面的方法就不行了,
那这时如果你的跳板机允许你本地客户端通过跳板机来做 ssh forward 的话,
你可以在你本地开发上述程序,只不过 ssh 要加个参数:
-o ProxyCommand='ssh 跳板机 -W %h:%p'
这样你本地 ssh host1 其实就等效于先 ssh 到跳板机然后再在跳板机上 ssh host1,
并且你的私钥仍然存在你本地。
如果你的跳板机不支持上述操作,那就没辙了。
ProxyCommand
Specifies the command to use to connect to
the server. The command string extends to
the end of the line, and is executed using
the user's shell `exec' directive to avoid a
lingering shell process.
Arguments to ProxyCommand accept the tokens
described in the TOKENS section. The command
can be basically anything, and should read
from its standard input and write to its
standard output. It should eventually con-
nect an sshd(8) server running on some
machine, or execute sshd -i somewhere. Host
key management will be done using the
Hostname of the host being connected
(defaulting to the name typed by the user).
Setting the command to none disables this
option entirely. Note that CheckHostIP is
not available for connects with a proxy com-
mand.
This directive is useful in conjunction with
nc(1) and its proxy support. For example,
the following directive would connect via an
HTTP proxy at 192.0.2.0:
ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
【 在 ckc 的大作中提到: 】
: 都是自己的机器,每台机器的ps1在装系统的时候就统一改过了
: 设置ps1的好处是可以自动把当前目录也带上去
: 不知道你说的本地修改是修改什么?wrapper又怎么搞?
--
修改:flw FROM 163.125.197.*
FROM 163.125.197.*