Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting remote "local echo" from Lua #6466

Open
dfaerch opened this issue Dec 6, 2024 · 1 comment
Open

Detecting remote "local echo" from Lua #6466

dfaerch opened this issue Dec 6, 2024 · 1 comment
Labels
enhancement New feature or request lua-api Adding or fixing something in the lua API

Comments

@dfaerch
Copy link

dfaerch commented Dec 6, 2024

I would like my password manager integration plugin to detect whether the password I'm about to "paste" will be echoed to the terminal, even when sudoing via SSH.

Currently, the only working method I have found is:

  • Output a few characters.
  • Check if they were echoed.
  • Delete them again.

This is not optimal because the characters will be interpreted by whatever software you are in (e.g., vim) if done accidentally.


Proposed Solution
I’d love to have a Lua function that can directly tell me if echo is on. IIRC, iTerm2 does something similar for its password manager, so I assume it’s technically possible.

Based on some online research, my understanding is that during SSH sessions, programs like sudo temporarily disable echo via stty -echo for password prompts. These PTY changes are forwarded over SSH to the terminal emulator using control sequences.

Since WezTerm likely already processes these terminal mode requests when the remote shell changes PTY flags, perhaps these changes (at least the echo state) could be tracked and exposed to Lua.


Other Things Tried
I also explored whether i could find special characters to be output that wouldn’t affect the application (e.g., vim) but could still be used to detect echo. Unfortunately, I haven’t had success with this approach.

@dfaerch dfaerch added the enhancement New feature or request label Dec 6, 2024
@wez wez added the lua-api Adding or fixing something in the lua API label Feb 11, 2025
@wez
Copy link
Member

wez commented Feb 11, 2025

https://wezterm.org/config/lua/pane/get_metadata.html#password_input is the closest thing we have to this functionality.
It only works for local terminal panes. There isn't currently a mux protocol equivalent to this function.
Note that running other terminal programs may hide this information from wezterm, even for local programs, so your remote ssh session may obscure this because they proxy ptys and may not propagate this status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lua-api Adding or fixing something in the lua API
Projects
None yet
Development

No branches or pull requests

2 participants