我没有设法通过其 ssh X11 管理功能使用 Paramiko python 模块。
我想像使用 ssh -X 选项一样使用它。
我尝试了几种解决方案,但在我的系统上没有任何效果。
这是我尝试过的代码:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.connect(machineName, username=xxx, password=xxx)
t = client.get_transport ()
chan = t.open_session ()
chan.request_x11 ()
chan.set_combine_stderr (True)
chan.exec_command (xxxxx) # the command that should display a X11 window
bufsize = -1
stdin = chan.makefile('wb', bufsize)
stdout = chan.makefile('rb', bufsize)
stderr = chan.makefile_stderr('rb', bufsize)
for line in stdout:
print '... ' + line.strip('\n')
client.close()
我也试过(而不是 exec_command):
chan.get_pty("vt100", 80, 50)
chan.invoke_shell()
chan.send(xxxxx) # the command that should display a X11 window
不幸的是,我的应用程序在 X11 窗口正常出现时冻结了。备注:如果我在没有显示 X11 窗口的情况下启动命令,它会完美运行。
谢谢你的帮助,
问候