SECURITY Clear screen on logout
Uit Gentoo Linux Wiki
Inhoud |
[bewerken] Recommended method
[bewerken] Using vi
You can use /etc/issue to clear the terminal by putting ansi escape sequences in the first line.
vi /etc/issue
Enter insert mode. In the first line type (without the spaces):
CTRL-V CTRL-ESC [2J CTRL-V CTRL-ESC [f
you should get this: {{Box File|/etc/issue|
^[[2J^[[f This is \n.\O (\s \m \r) \t
}}
This resets the terminal before the issue message is displayed. Note that copy-pasting won't work, you should type that sequence.
If CTRL-ESC brings ProcessTable in KDE try another method using vi:
clear >> /etc/issue vi /etc/issue Gdd1GPZZ
The last line tells vi to move the character sequence generated by clear command to the first line of file, saves the file and exits.
[bewerken] Using nano
clear >> /etc/issue
Now, open /etc/issue with nano or your favorite editor and move the code to the top of the file. nano /etc/issue
you should end up with this: {{Box File|/etc/issue|
^[[H^[[2J This is \n.\O (\s \m \r) \t
}}
[bewerken] Other methods
[bewerken] Method 1
If you are working on a server, or a public workstation, for example in an university, you might want to make sure no-one reads screen-content which is left over by your last session after typing "logout".
To achieve this, you simply need to add the command clear to your ~/.bash_logout.
echo "clear" >> ~/.bash_logout
should do the trick.
[bewerken] Method 2
A variant to method 1 is appending this to /etc/profile (or ~/.bashrc)
| File: /etc/profile or ~/.bashrc |
alias exit="clear && logout" |
- Note: When I used "clear" in my ~/.bash_logout I could still use Shift + PageUp to scroll up in the terminal. A solution that works for me is to replace "clear" with "reset" in ~/.bash_logout.
[bewerken] Method 3
A variant on Method 2 is to append this to /etc/profile (or ~/.bashrc)
| File: /etc/profile or ~/.bashrc |
alias exit="reset && logout" |
[bewerken] Method 4
If you do clear on logout some of the last lines still will be available "SHIFT+PageUP". This will clear the history.
| File: /etc/inittab |
... # getty-programs for the normal runlevels # <id>:<runlevels>:<action>:<process> # The "id" field MUST be the same as the last # characters of the device (after "tty"). #1:2345:respawn:/sbin/mingetty --noclear tty1 1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6 ... |
- Note: I use mingetty
- Note: "SHIFT+PageUP" will not work if you changed console to another one and then back to original one, i.e. you are at "Alt+F1" then "Alt+F2" and back to "Alt+F1".
[bewerken] Method 5
Not the best way, but it works.
cp /etc/issue /etc/issue.bak; clear > /etc/issue; cat /etc/issue.bak >> /etc/issue; rm /etc/issue.bak
I use a script to generate my /etc/issue every 15 minutes, so having a 'clear > /etc/issue' at the top was what i did to have this affect.
[bewerken] Method 6
Another dirty way is to flush the screen with a lot of random chars from /dev/urandom before logging out.
cat /dev/urandom & sleep 3; logout
After this, the whole scrollback buffer is overwritten with random chars.
[bewerken] Method 7
Clean and easy: add "trap clear 0" to your /etc/profile - cheerz :)
