0 votes
by (170 points)
edited by

Hi all,

We are planning to set up a SCP server and needs to get the client IP when it uploads/downloads files.

It seems that the upload/download evens of the FileServer do not provide the information of the client IPs. In our environment multi clients from different machines can only share the same user name / password to connect to the server (for management reason).

Any workaround to get the client IP? This is a critical requirement for our usage, any help appreciated.

Allison

2 Answers

0 votes
by (147k points)
 
Best answer

Rebex File Server 2017 R4 adds Session property to FileUploaded and FileDownloaded event arguments and it includes the client endpoint, making it very simple to determine the client's IP address:

server.FileUploaded += (sender, e) =>
{
    // get session's IP address
    IPAddress address = ((IPEndPoint)e.Session.ClientEndPoint).Address;
    ...
};
0 votes
by (147k points)
edited by

Update: This approach is no longer necessary. See the new answer for a simple solution available since Rebex File Server 2017 R4.


Hi,

The solution proposed in another answer should be suitable for this scenario as well. Please give it a try and let us know if you run into any problems.

To enable SCP in addition to SFTP, you would have to add the following line as well:

server.Bind(22, FileServerProtocol.Scp);
by (170 points)
Thanks Lukas. This solution does work and solves our problem.
...