console output/history auto clears after logout from ssh session #19844

Closed
opened 2026-01-31 06:55:08 +00:00 by claunia · 5 comments
Owner

Originally created by @mfatty on GitHub (May 9, 2023).

Windows Terminal version

1.16.10262.0

Windows build number

10.0.22621

Other Software

Cygwin
Windows Powershell

Steps to reproduce

Start a new local terminal session (either Powershell or Cygwin)
Ssh to remote linux host (ssh user@ip)
On remote host via the ssh session, run some linux commands and get some output on console
Now I like 100 lines of output on console.
Type 'exit' to logout of ssh session
All the 100 lines of console output/history I had generated from the ssh session are gone.

remote-session.txt

when I type 'exit', everything clears on the console and all I get on the terminal is
Connection to <ip-address> closed.
PS C:\Users\username>

Expected Behavior

I expect to the terminal to keep the console output/history as I switch between local to remote sessions on the same terminal tab.

Actual Behavior

Terminal deletes console output/history when I logout from remote ssh session.

Originally created by @mfatty on GitHub (May 9, 2023). ### Windows Terminal version 1.16.10262.0 ### Windows build number 10.0.22621 ### Other Software Cygwin Windows Powershell ### Steps to reproduce Start a new local terminal session (either Powershell or Cygwin) Ssh to remote linux host (ssh user@ip) On remote host via the ssh session, run some linux commands and get some output on console Now I like 100 lines of output on console. Type 'exit' to logout of ssh session All the 100 lines of console output/history I had generated from the ssh session are gone. [remote-session.txt](https://github.com/microsoft/terminal/files/11428474/remote-session.txt) when I type 'exit', everything clears on the console and all I get on the terminal is `Connection to <ip-address> closed.` `PS C:\Users\username>` ### Expected Behavior I expect to the terminal to keep the console output/history as I switch between local to remote sessions on the same terminal tab. ### Actual Behavior Terminal deletes console output/history when I logout from remote ssh session.
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 06:55:08 +00:00
Author
Owner

@lhecker commented on GitHub (May 9, 2023):

What are the contents of your ~/.bash_logout in your remote host? Does it contain anything related to "clear(ing)"?

@lhecker commented on GitHub (May 9, 2023): What are the contents of your `~/.bash_logout` in your remote host? Does it contain anything related to "clear(ing)"?
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (May 9, 2023):

remote-session.txt shows $SHELL being /usr/bin/zsh; thus the contents of ~/.bash_logout may be irrelevant. Instead check $ZDOTDIR/.zlogout and /etc/zlogout.

With hardware terminals, I think clearing the screen during logout was common practice in order to prevent the next user of the terminal from reading the output before logging in.

@KalleOlaviNiemitalo commented on GitHub (May 9, 2023): [remote-session.txt](https://github.com/microsoft/terminal/files/11428474/remote-session.txt) shows $SHELL being `/usr/bin/zsh`; thus the contents of `~/.bash_logout` may be irrelevant. Instead check `$ZDOTDIR/.zlogout` and `/etc/zlogout`. With hardware terminals, I think clearing the screen during logout was common practice in order to prevent the next user of the terminal from reading the output before logging in.
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 13, 2023):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@microsoft-github-policy-service[bot] commented on GitHub (May 13, 2023): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 13, 2023):

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@microsoft-github-policy-service[bot] commented on GitHub (May 13, 2023): This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
Author
Owner

@mfatty commented on GitHub (May 14, 2023):

❯ cat ~/.bash_logout
# ~/.bash_logout
.
.
$ZDOTDIR/ does not have a logout file
.
.
❯ cat /etc/zlogout
# /etc/zlogout and ~/.zlogout are run when an interactive session ends
clear
.
.
So, /etc/zlogout is in fact the problem. I commented clear in /etc/zlogout and that fixed the issue.
Thank you @lhecker @kalle

@mfatty commented on GitHub (May 14, 2023): `❯ cat ~/.bash_logout ` `# ~/.bash_logout` . . ` $ZDOTDIR/` does not have a logout file . . `❯ cat /etc/zlogout` `# /etc/zlogout and ~/.zlogout are run when an interactive session ends` `clear` . . So, /etc/zlogout is in fact the problem. I commented `clear` in `/etc/zlogout` and that fixed the issue. Thank you @lhecker @kalle
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19844