Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Here is what I am looking for:

A way to log individual SSH sessions on SunOS. I would like to have the files kept separate based upon the hostname of the device I am SSHing into. I am only using the CLI interface so GUI tools will not work. Some of the options I am considering include either using the script command or the screen utility. If someone could explain how they log multiple sessions to multiple devices via an automated method. So for example if you could include either a .bashrc example or a script that I could use so I am not manually entering the same commands every time I login that would be ideal.

I was thinking perhaps a script could first call either screen or script and begin the logging based on the hostname I am SSHing into and then call SSH to start the connection. Thanks!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

To create a raw logfile of everything that occurs during a session, including screen control escape codes, I would use tee.

In your .bashrc create a function:

myssh () { ssh $1 2>&1 | tee -a ~myusername/logdir/$1.log; }

And then create an alias:

alias ssh=myssh

Now, assuming you have created logdir, anytime you make an ssh connection, the contents of your session will be appended to the logfile based on the connection name.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.