Skip to content

[SUPPORT] - Paramiko + sudo-1.9.17p2 + stdin input for sudo -S does not work as expected #2627

Open

Description

@ArthurGarnier

Are you using paramiko as a client or server?

Client

What feature(s) aren't working right?

SSH

What version(s) of paramiko are you using?

5.0.0

What version(s) of Python are you using?

3.12.13

What operating system and version are you using?

RHEL8 (on client), RHEL9.8 (on server)

If you're connecting as a client, which SSH server are you connecting to?

openssh-server-9.9p1-7.el9_8

If you're using paramiko as part of another tool, which tool/version?

No response

What are you trying to do with paramiko?

Running command remotely with "sudo -S" as privilege escalation.

How are you trying to do it, and what's happening instead?

Since sudo-1.9.17p2-3.el9_8.x86_64 (coming from sudo-1.9.5p2-15.el9_7.x86_64, next to RHEL9.8 release), running sudo -S cmd using paramiko does not send the password correctly.

Minimal script used :

from paramiko import AutoAddPolicy
from paramiko.client import SSHClient
from getpass import getpass
import os
import time

client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
USER_PASS=getpass()
client.connect(
    "REMOTE_SRV_RHEL_9.8",
    username=os.getlogin(),
    password=USER_PASS,
    allow_agent=False,
    look_for_keys=False,
)
(stdin, stdout, stderr) = client.exec_command("sudo -S echo 'test'", get_pty=True)
# time.sleep(0.1)
stdin.write(f"{USER_PASS}\n")
stdin.flush()
print(stdout.readlines())
print(stderr.readlines())

Note :

  • Downgrading sudo on the remote server and it works
  • Adding a sleep (0.1s is enough), and it works too
  • When the issue happens, wait few minutes and sudo will raise sudo: timed out reading password\r\n', 'sudo: a password is required
  • With get_pty=False it also works

Anything else?

No response

Activity

  1. changed the title [-][SUPPORT] - <title>[/-] [+][SUPPORT] - Paramiko + sudo-1.9.17p2 + stdin input for sudo -S does not work as expected[/+] on May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions