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.

  • I asked same question in stackoverflow community also but I was unable to migrate this from there to here. so i added here also. stackoverflow.com/questions/26101107/… Sep 29, 2014 at 13:35
  • Please delete one of the two. You should only ask on one of the sites of the SE network unless you tailor the question to fit each community. See here for more on cross-posting.
    – terdon
    Sep 29, 2014 at 13:38
  • how to migrate my question from stackoverflow to here ? Sep 29, 2014 at 13:47
  • Just delete the one on Stack Overflow.
    – terdon
    Sep 29, 2014 at 13:51

1 Answer 1


As I understand it, you have two issues you're looking to solve:

  1. Establish and log the identity of the remote user from the local sshd
  2. 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .