That's a little unclear.
When you ssh to the remote machine, you are executing commands in the shell on the remote machine. You can certainly have the shell keeping a history on the remote machine. I use ksh. The history file is .sh_history in my home directory. I use "set -o vi" to get vi keystroke editing of the history file. So when I'm at the command line, esc k gets me the last command, etc.
On the other hand, you might be asking how your local machine might record the commands that you execute on the remote machine. I don't think there is any way of doing that. If you had keystroke logging, you would basically have to emulate your shell on the remote system to put the keystrokes together into the commands, accounting for back spaces, vi editing keystrokes, etc.
A totally different viewpoint is the scrollback on your terminal window. I've set that to essentially unlimited on my desktop computer. So, even after I've logged out or even shutdown the remote machine, I can scroll back through my window and see what I did.
Hope that helps at least to clarify the scope of your question.