sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.98k stars 931 forks source link

How to obtain the Session.SessionId in consuming code? #637

Open BBauer42 opened 4 years ago

BBauer42 commented 4 years ago

I'd like to get the SessionId in code that is using the SSH.NET library. Unfortunately, the SessionId is internal. I can access it when debugging, but not in code. Is there a method somewhere (or some other way) to get the SessionId (which is a byte array)? If not, I will have to manipulate the source to expose the SessionId myself. Please advise. Thanks.

BBauer42 commented 4 years ago

Anyone?

elgonzo commented 4 years ago

Currently you only have two options (i am not recommending one over the other; it's your choice):

(1) Don't use the prebuilt library/nuget package (it's probably a good idea anyways, as the released pre-built library is quite outdated), but download the source code from Github here. Then modify the code to make the desired member(s)/type(s) public. (as you already mentioned)

(2) Stick with the unmodified SSH.NET code, and use reflection to access non-public members you are interested in.