What's the best method of logging a BASH shell session to a file on the host machine?
The preferred output format would be equivalent to PuTTY's "printable output" log setting, as viewed by the user inclusive of input and exlusive of ncurses control character data.
It might be worth looking at shell or system auditing programs like rootsh or sudosh.
You could start gnu screen and use the log feature. I don't know of anything that is going to give you a really good log for ncurses applications like top.
man screen
TTYrec is probably the easiest solution. You can use the original:
http://0xcc.net/ttyrec/index.html.en
Or roll your own:
http://en.wikipedia.org/wiki/Ttyrec
Or, you could get all old school and | all your commands to tee command.timestamp.tee
The
script
program will take a complete log of your shell session. Dunno if it's equivalent to any PuTTY thing.You can try to use http://xgu.ru/wiki/LiLaLo It is made in Russia, so documentation is also in Russian, but Google Translate will help you. Here is an example of the output:
(source: xgu.ru)
I'm not sure exactly what you're trying to achieve here. Is this for training or forensics? If you want something that produces nice readable log files you're probably out of luck. If you're looking at being able to playback sessions, ttyrec is what you're after. You can run it as part of a login script to capture a user's session, but make sure you use 'trap' to stop a user from exiting ttyrec and getting back to a shell.
All entered commands are written into .bash_history file, normally in your home. You can set count of lines that are stored via HISTFILESIZE setting.
There are no timestamps and output, however.
If this is really needed, I'd make a wrapper around bash, copying stdin and stdout to a file and work through that.