Maximus5 / ConEmu

Customizable Windows terminal with tabs, splits, quake-style, hotkeys and more
https://conemu.github.io/
BSD 3-Clause "New" or "Revised" License
8.62k stars 575 forks source link

motd is duplicated when working with Win32-OpenSSH #1649

Open FranklinYu opened 6 years ago

FranklinYu commented 6 years ago

I'm not sure whether this is a third-party problem; both components seem necessary to reproduce it.

Versions

ConEmu build: 180626 x64 OS version: Windows 10 x64 Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): cmd, Git Bash, PowerShell (5/6) Win32-OpenSSH: 7.7p1, LibreSSL 2.6.4

Problem description

When I SSH into Linux machines, the motd (Message of the Day) is duplicated. Win32-OpenSSH is required to reproduce this issue.

Steps to reproduce

  1. Install Win32-OpenSSH.
  2. Create a task with command %ProgramFiles%\OpenSSH-Win64\ssh.exe my-linux-machine.
  3. Run the task (in a new tab).

Actual results

The motd is duplicated like

Last login: Thu Jul 19 13:10:30 2018 from 192.0.2.1
Last login: Thu Jul 19 13:10:30 2018 from 192.0.2.1

This happens to many Unix-like distributions, including Fedora, Ubuntu, Arch, and macOS.

Expected results

Last login: Thu Jul 19 13:10:30 2018 from 192.0.2.1

Control Group

These experiments do not show this issue:

  1. Running Win32-OpenSSH within PowerShell from Windows 10.
  2. Running Win32-OpenSSH from Windows 10 search box.
  3. Running the PowerShell task that came with ConEmu, then run Win32-OpenSSH in the PowerShell.
  4. Edit the task and replace the SSH binary with the one that came with Git Bash.

From above I conclude that ConEmu and Win32-OpenSSH are required to reproduce.

Maximus5 commented 6 years ago

Please run ConEmu with -log switch and provide the logs with duplicated lines. When you run ssh (Win32-OpenSSH) it does not push ANSI to ConEmu, but writes process sequences internally and calls WinAPI functions to produce output. ConEmu just shows that output.

FranklinYu commented 6 years ago

Sorry for late reply. I tried running "path\to\ConEmu.exe" -log in cmd.exe, but it does not produces any log in cmd.exe. Is there any log file generated elsewhere? I scanned through %AppData% but didn't find any ConEmu related folder.

Maximus5 commented 6 years ago

Hmm? I didn't get your point with "log in cmd.exe". https://conemu.github.io/en/LogFiles.html

Maximus5 commented 6 years ago

And perhaps more interesting are ANSI log files: https://conemu.github.io/en/AnsiLogFiles.html

FranklinYu commented 6 years ago

https://gist.github.com/franklinyu/6f5b78b9efbeb9385d529d1cc8ca5475

a2468834 commented 4 years ago

This problem still exists. ConEmu build: 200928 x64 OS version: Windows 10 Pro Ver. 2004 SSH version: OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5

BTW, I have tried PuTTY to ssh into Linux server, and it works correctly. PuTTY would display only one motd.

a2468834 commented 4 years ago

Found a feasible solution: If I used chcp 65001 which is used to changes cmd console code page before ssh, I would get only one motd message. Probably, this problem is caused by some encoding issues related to UTF-8.

a2468834 commented 3 years ago

Here is the way to setup ConEmu with chcp 65001 while launching: (1) Go to Settings > Startup > Environment (2) Enter the following string into the right panel: chcp 65001 (This command will make cmd.exe change code page number to UTF-8.)