sshnet / sshnet/SSH.NET

Feature request: Provide a way to bind the SSH clients to a local IP

Open
#42 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

Hi,

Would you consider adding LocalIP (and LocalPort defaulting to 0) property to the ConnectInfo? I have a multi-IP server and need to bind to a particular IP for the SFTP to go thru the firewall.
I know that Socket.Bind is not supported by all target frameworks.

I ended up modifying the ConnectInfo with the two properties, the PasswordConnectionInfo to add the necessary constructors, the Session.SocketConnect to optionally construct an IPEndPoint and the SocketAbstraction.Connect to pass the local EndPoint and do a socket.Bind.
I used FEATURE_SOCKET_SYNC to surround the socket.Bind to make the code compile.
Of course this is a hack for my needs only.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ConnectInfo and PasswordConnectionInfo, then follow the connection path through Session.SocketConnect to SocketAbstraction.Connect. Review how FEATURE_SOCKET_SYNC affects socket support. Done means local IP and LocalPort, defaulting to 0, can be passed through and used to bind the socket before connecting, while supported target frameworks still compile.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.