Subject: Re: bug#75746: 31.0.50; Can't get password promote from plink 0.82

From: Michael Albinus <[email-masked]>
Date: Sat, 01 Feb 2025 10:25:47 +0100

Eli Zaretskii <[email-masked]> writes:

Hi Eli,

>> > Does the user name or password include non-ASCII characters?
>>
>> No, at least not in my own test. I've used albinus@gandalf as tartget,
>> which sounds kind of magic, but is just ASCII.
>>
>> No password entered, because the password prompt didn't appear.
>>
>> > Does Tramp assume something about the encoding of stuff sent to plink
>> > and received from plink?
>>
>> Not that I'm aware of.
>
> Then maybe plink now expects UTF-16 encoding of text sent to it?

No. I've set the coding-system-argument of the shell buffer to
utf-16. The result is unreadable text.

> Or maybe we should talk to the PuTTY developer and ask him to give us
> ideas about what could be wrong and how to solve it?

Yep. But first, here is a recipe w/o Tramp, so people can reproduce it
locally. On my Windwo 11 VM, I have installed plink 0.82. If I use the
Windows console (cmd.exe), I can do the following:

--8<---------------cut here---------------start------------->8---
C:\Users\albinus>plink -ssh -t gandalf " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh  -i "
The host key is not cached for this server:
  gandalf (port 22)
You have no guarantee that the server is the computer you
think it is.
The server's ssh-ed25519 key fingerprint is:
  ssh-ed25519 255 SHA256:C96ox1WRNvHtxKlAVJYPlAF77hiCkHPvwgD71+IpY0k
If you trust this host, enter "y" to add the key to Plink's
cache and carry on connecting.
If you want to carry on connecting just once, without adding
the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n, Return cancels connection, i for more info)
--8<---------------cut here---------------end--------------->8---

This looks normal.

Using Emacs 29.4 on that machine, I set shell-file-name to
"cmd.exe". Then I do 'M-x shell', opening the Windows console in
Emacs. Here we see:

--8<---------------cut here---------------start------------->8---
c:\Program Files\Emacs>plink -ssh -t gandalf " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh  -i "
plink -ssh -t gandalf " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh  -i "
--8<---------------cut here---------------end--------------->8---

No output, and the program does not return.

However, if I use a non-existing host name, plink reports this:

--8<---------------cut here---------------start------------->8---
c:\Program Files\Emacs>plink -ssh -t hostnamedoesnotexist " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh  -i "
plink -ssh -t hostnamedoesnotexist " env 'TERM=dumb' 'PROMPT_COMMAND=' 'PS1=#$ ' /bin/sh  -i "
Unable to open connection:
Host does not exist
--8<---------------cut here---------------end--------------->8---

I'm a n00b wrt Microsoft Windows. Perhaps somebody can investigate?

Best regards, Michael.