Search code examples
sftpssh.net

Select network interface to be used by SftpClient class in SSH.NET


Is there any way to set local network interface to be used by SftpClient class in SSH.NET?


Solution

  • I believe it's not possible with the SSH.NET.

    You would have to change implementation of the the SocketAbstraction.Connect method to call Socket.Bind before Socket.ConnectAsync.


    Though are you sure you need to set the default interface?

    An FTP client may need to use a specific network interface to listen on for incoming connecting in an active FTP mode. But for outgoing connections (SSH/SFTP uses outgoing connections only), one typically does not need to select a network interface.