Paramiko X11 模式与 python 编程
我无法使用 Paramiko python 模块通过其 ssh X11 管理功能。
我想像使用 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 窗口的情况下启动命令,则它可以正常工作。
谢谢您的帮助,
问候
I do not manage to use the Paramiko python module passing through its ssh X11 management functionality.
I would like to use it as if I used the ssh -X option.
I have tried several solution but nothing work on my system.
Here is the code I tried:
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()
I also tried (instead of the exec_command) :
chan.get_pty("vt100", 80, 50)
chan.invoke_shell()
chan.send(xxxxx) # the command that should display a X11 window
Unfortunately, my application freezes at the moment that the X11 window should normally appear. Remark : If I launch a command without a X11 window displaying, it works perfectly.
Thank you for your help,
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我需要使用 paramiko 在另一个 X11 窗口中运行 GUI,并找到了这篇文章。我认为您可能需要添加几行才能使其工作。这都是关于处理程序参数的。
此处,为传入 X11 连接分配一个功能。
并写一个简单的。
之后它应该会弹出一个新窗口。至少它对我有用。
I needed to use paramiko to run the GUI in another X11 window and found this post. I think you may need to add few lines to make it work. It's all about the handler parameter.
Here, assign a function for incoming X11 connections.
And write a simple one.
It should pop out a new window after that. At least it works for me.
阅读paramiko代码,我意识到paramiko只实现了一种建立x11通道的方法。它不会将通道连接到本地 x11 显示器。那留给你了。
请参阅此答案,了解如何执行此操作的工作示例:https://stackoverflow.com/a/12903844/72911
Reading the paramiko code, I realized that paramiko only implements a way to establish an x11 channel. It does not connect the channel to the local x11 display. That is left to you.
Please see this answer for a working example of how to do this: https://stackoverflow.com/a/12903844/72911