ssh_send_stdin
Send text or control characters to stdin of a spawned SSH job, with options to append newline or close stdin. Use for password prompts, REPL commands, or signaling processes.
Instructions
Write bytes to the stdin of a running job (one spawned by ssh_spawn). Used for password prompts (sudo -S -p ''), REPL input (python, node), and any interactive CLI that expects keystrokes.
By default a trailing '\n' is appended so the remote program sees a complete line (this is what 'sudo -S' and most line-based REPLs need). Set newline=False to send raw bytes without the terminator — useful for control characters (e.g. data='\x03' to send ^C to a pty-mode job, or data='\x04' for ^D / EOF).
Set close_stdin=True to close the remote's stdin AFTER the write, which signals EOF to programs like 'cat', 'wc', 'sort'. Leaving it open (default) lets you make more writes to the same job.
IMPORTANT: for password input, pair this with ssh_spawn(pty=True) AND the command 'sudo -S -p ""'. Without pty=True, sudo refuses to read the password from a pipe on most distros. Without the -p "" flag, sudo writes its prompt to stdout, which mixes into ssh_tail output.
Payload size is capped at 64 KiB per call. For larger input use ssh_upload to place a file on disk, then have the command read from it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| job_id | Yes | The id returned by ``ssh_spawn``. | |
| data | Yes | The text to send, UTF-8 encoded on the wire. Can be empty; an empty ``data`` with ``newline=True`` sends just a single ``\n`` (useful for "press Enter" prompts). Control characters are passed verbatim, so ``"\x03"`` sends ^C to a pty-mode job's line discipline. | |
| newline | No | When True (default), append a ``\n`` to ``data`` unless it already ends with one. When False, send exactly the bytes in ``data`` — useful for control characters (``\x03`` for ^C, ``\x04`` for ^D) and for multi-write sequences that assemble a line progressively. | |
| close_stdin | No | When True, close the remote's stdin channel AFTER the write completes. Signals EOF to the remote program. When False (default), stdin stays open and you can make subsequent ssh_send_stdin calls. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||