首页 > 解决方案 > 客户端中的exec_command和Paramiko的频道之间的区别?

问题描述

在 Python 包 Paramiko 中,和中存在exec_command方法,它们有什么区别?channel.pyclient.py

标签: pythonsshparamiko

解决方案


Channel是一个您通常不应该使用的低级 API。

SSHClient.exec_command调用和Channel.exec_command之后创建stdin//对象并将它们作为 3-touple 返回。你必须自己创建这些对象(因为没有它们是无用的)。stdoutstderrChannelChannel.exec_command

另请参见Paramiko exec_command failed with 'NoneType' object is not iterable

此外,分别触发和的SSHClient.exec_commandhasget_pty和参数。environmentChannel.get_pty()Channel.update_environment

检查SSHClient.exec_command源代码


推荐阅读