Identifying User that raise custom command

0 votes
asked 5 days ago by Stony Kong (140 points)

The SFTP Server supports implementation of custom command via SSH session. If there is more than one user login to the Server, what is the proper way for the Server to identify the user that raise that custom command ?

1 Answer

0 votes
answered 5 days ago by Lukas Pokorny (95,290 points)

An instance of ShellCommandEventArgs passed to FileServer's ShellCommand event features a User property that identifies the user who raised the command:

server.ShellCommand += (sender, e) =>
{
    if (e.Command == "whoami")
    {
            e.WriteLine(e.User.Name);
    }
};
commented 5 days ago by Stony Kong (140 points)
Dear Lukas,

Thank you for the information.

Best Regards,
Stony Kong
...