Python 在帕拉米科海峡开通更多管道
当通过Paramiko连接到ssh服务器时,使用Python 在帕拉米科海峡开通更多管道,python,ssh,pipe,paramiko,Python,Ssh,Pipe,Paramiko,当通过Paramiko连接到ssh服务器时,使用SSHClient读取stdios非常容易 client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('127.0.0.1', username='rusername', password='password') stdin, stdo
SSHClient
读取stdios非常容易
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('127.0.0.1', username='rusername', password='password')
stdin, stdout, stderr = client.exec_command(cmd)
我可以通过客户端访问使用过的频道
。获取\u transport()。\u频道
(也许有更好的方法?)
有没有可能在这条通道上多开几条管道?我在ssh服务器上调用一个Python脚本,以便在服务器端脚本中打开fd进行编写
Channel.makefile()
在我所做的小测试中似乎与另一个管道/fd不相关。我可能误解了文档 要在远程服务器上打开文件(用于读取或写入),可以使用open\u sftp
:
sftp = client.open_sftp()
with sftp.open("/tmp/somefile", "w") as outfile:
outfile.write("my data")
如果我在服务器上创建一个命名管道,这可能会很有帮助,我可能会通过您的示例在客户机上读取它,然后从服务器代码中写入它。。。我只是希望有一个更精简的方法。