This little trick allows you to share your terminal session with other users. For example, it could be helpful for making remote demos of GNU/Linux to your unexperienced users or to capture what you do in a session.
For this trick to work we will use these system utilities:
- script: to dump everything we type on the terminal to a file
- mkfifo: to create a FIFO (named pipes)
We want that everything typed in on hostA to be reflected in a session opened from hostB. Here we go…
From hostA issue these commands:
cd /tmp
mkfifo funforme; script -f funforme
And from hostB…
ssh user@hostA
cd /tmp
cat funforme
Now everything you type on hostA will be reflected in hostB. Funny, isn’t it? To exit the session, simply type exit from hostA and CTRL+C from hostB. You could also delete the named pipe funforme.