Skip to content

Server.reboot operation incompatible with ProxyCommand #1708

@Tbruno25

Description

@Tbruno25

Describe the bug

When connected to a host with ProxyCommand in its SSH config, the server.reboot operation hangs indefinitely.

The issue is likely due to L89.

  • The server drops the connection as expected
  • The proxy process remains alive
  • Because the proxy is still running, the connection is not seen as closed
  • pyinfra waits indefinitely for a return code that will never arrive

Setting paramiko.transport.set_keepalive(4) resolves the hang, but isn't a viable fix — the transport object isn't exposed by pyinfra, and the stale proxy connection causes threading/atexit errors during teardown.

To Reproduce

  1. Configure a host with ProxyCommand ssh -W %h:%p <proxy_host> in its~/.ssh/config
  2. Perform aserver.reboot operation

Expected behavior

The operation should detect that the server has gone away (or timeout) and proceed with reconnection.

Meta

❯ uv run pyinfra --support

    System: Darwin
      Platform: macOS-26.4.1-arm64-arm-64bit-Mach-O
      Release: 25.4.0
      Machine: arm64
    pyinfra: v3.6.1
      click: v8.3.1
      distro: v1.9.0
      gevent: v25.9.1
      jinja2: v3.1.6
      packaging: v26.0
      paramiko: v3.5.1
      pydantic: v2.12.5
      python-dateutil: v2.9.0.post0
      typeguard: v4.5.1
      typing-extensions: v4.15.0
    Python: 3.13.12 (CPython, Clang 21.1.4 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionIssues that need opinions!

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions