Skip to content

PTY mode: sudo password input fails in interactive sessions #40

@inureyes

Description

@inureyes

Problem

When connecting via bssh -p 8222 user@host and trying to run sudo -s or passwd, password input doesn't work correctly. The same commands work fine with regular ssh command.

Root Cause Analysis

After deep investigation of the codebase, identified two critical issues:

1. Empty Terminal Modes (PRIMARY ISSUE)

Location: src/pty/session.rs:171

self.channel.request_pty(
    false,
    &self.config.term_type,
    width,
    height,
    0,   // pixel width
    0,   // pixel height
    &[], // ❌ PROBLEM: terminal modes (empty array)
)

Impact:

  • SSH PTY is requested with empty terminal modes array
  • sudo and passwd require specific terminal modes (ECHO, ICANON, ISIG, etc.) to securely handle password input
  • Empty array causes SSH server to use defaults that don't match sudo's requirements

Required Terminal Modes:

  • ECHO (53): Control echo for password masking
  • ICANON (54): Canonical mode for line-based input
  • ISIG (50): Signal generation (Ctrl+C, etc.)
  • Additional modes for proper terminal behavior

2. Potential Duplicate PTY Requests

Flow:

  1. connect_to_node_pty()client.request_interactive_shell() (requests PTY)
  2. PtySession::run()initialize()channel.request_pty() (requests PTY again!)

Impact: May cause conflicts or undefined behavior

Testing

Tested with -t flag to force PTY mode:

bssh -t -p 8222 user@host

Still fails, confirming this is a code-level bug, not a configuration issue.

Solution Requirements

  1. Set proper terminal modes in channel.request_pty() call
  2. Remove duplicate PTY request logic
  3. Ensure compatibility with interactive programs (sudo, passwd, vi, etc.)

References

  • SSH Protocol: RFC 4254 Section 6.2 (Requesting a Pseudo-Terminal)
  • Terminal modes list: RFC 4254 Section 8 (Encoding of Terminal Modes)
  • Related code: src/pty/session.rs:156-184, src/commands/interactive.rs:511-640

Priority

High - Affects core interactive functionality

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions