我使用 Paramiko ssh 连接到服务器并想要列出输出。但它只显示了一半的输出。输出末尾有一个 --More--
。如何增加缓冲区以显示完整输出?
以下是我的脚本的一部分:
SERVER_ssh = paramiko.SSHClient()
SERVER_ssh.load_system_host_keys()
SERVER_ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
SERVER_ssh.connect(hostname=SERVER_PLATFORM, port=SERVER_SSH_PORT, username=SERVER_ID, password=SERVER_PASSWORD)
except (AttributeError, TimeoutError) as err:
SERVER_ssh.close()
exit('Connection to SERVER fails')
with SSHClientInteraction(SERVER_ssh, timeout=20, display=True, buffer_size=8192) as interact:
interact.send(command)
time.sleep(2)
interact.expect(r'(.+)')
cmd_output_ssh = interact.current_output_clean
SERVER_ssh.close()
最佳答案
SSHClientInteraction
构造函数具有 tty_height
参数,默认为 24。
(假设您使用 paramiko-expect
library )
关于python - 如何增加 Paramiko SSH 客户端上的向后滚动缓冲区?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57683773/