How to record or log telnet session using the command line?

Solution 1:

First run 'script' and specify the log file

script mylogfile.log

Then a new bash session is initialized and all you need to do is run telnet.

When you're done just quit telnet, and type exit to stop recording. All the output will be in mylogfile.log

Solution 2:

You should be able to do what you want with 'tee'

telnet HOST | tee -i session-recording.log

You still can login and your password will not display in the recording.

Solution 3:

You can use gnu screen as a telnet client to do this:

With gnu screen version 4.05.01 or later, you can specify the log file name on the command line: screen -L -Logfile session.txt //telnet 10.10.0.10 23

This will log a telnet session with 10.10.0.10:23 to session.txt - The port number is for illustration only, and not actually needed if you're on the standard port 23.

You can also turn on/off logging while the session is in progress. See https://unix.stackexchange.com/questions/240796/gnu-screen-how-to-enable-or-disable-logging-while-screen-is-already-attached