I need to know how to copy a file from local server to remote server automatically after login using ssh. actually In my local server so many users are there with their local userid . but they will login as root in the remote server. I need to copy the user's local userid into the remote server so we can keep record who all logged into the server. if we can save the history of commands run by user the it is more profitable.
As I understand it, you have two issues you're looking to solve:
- Establish and log the identity of the remote user from the local sshd
- Log the commands run by the user
When it comes to item 1, you might able to use the solution (per-user unique keys) offered in answer to this stackoverflow question about checking the identity of the remote ssh user. This alternate approach uses a connection back to the originating machine.
I know more about item 2, logging the commands. My older answer to command logging outlines the three methods I know of.