客户端exec_command与Paramiko通道的差异?



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

Channel是一个低级API,一般不应该使用。

SSHClient.exec_command调用Channel.exec_command,然后创建stdin/stdout/stderr对象,并将它们作为3- double返回。使用Channel,您将不得不自己创建这些对象(因为没有它们,Channel.exec_command是无用的)。

参见Paramiko exec_command fails with 'NoneType'对象不可迭代。

此外,SSHClient.exec_command具有分别触发Channel.get_pty()Channel.update_environmentget_ptyenvironment参数。

检查SSHClient.exec_command源代码

最新更新