【问题标题】:How to increase scroll back buffer on Paramiko SSH client?如何在 Paramiko SSH 客户端上增加回滚缓冲区?
【发布时间】:2020-01-01 04:07:30
【问题描述】:

我使用 Paramiko 连接到服务器并希望列出输出。但它只显示了一半的输出。输出末尾有一个--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()

【问题讨论】:

  • 你在运行什么命令?

标签: python python-3.x ssh terminal paramiko


【解决方案1】:

SSHClientInteraction构造函数有tty_height参数,默认为24。

(假设您使用paramiko-expect library

【讨论】:

    猜你喜欢
    • 2013-01-21
    • 2013-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 2015-02-21
    • 2013-10-27
    • 1970-01-01
    相关资源
    最近更新 更多