Hi,
Is there a current method to share a SSH connection between SshClient ScpClient and SFTPClient?
I couldn't find an obvious method so resolved the issue by modifying BaseClient and ScpClient as follows,
BaseClient.cs
ScpClient.cs
To test the modifications I created the following application,
TestProgram.cs
Thoughts? The TestProgram works fine.
Is there a current method to share a SSH connection between SshClient ScpClient and SFTPClient?
I couldn't find an obvious method so resolved the issue by modifying BaseClient and ScpClient as follows,
BaseClient.cs
///<summary>/// Gets current session.///</summary>public Session Session { get; protectedset; }
public ScpClient(Session establishedSession) : this (establishedSession.ConnectionInfo) { base.Session = establishedSession; }
TestProgram.cs
var sshClient = new SshClient(host, username, password); sshClient.Connect(); var scpClient = new ScpClient(sshClient.Session); Console.WriteLine("SCP connect? " + scpClient.IsConnected); FileInfo fileInfo = new FileInfo(@"C:\mybin\temp.exe"); scpClient.Upload(fileInfo, "/home/temp/test/temp.exe"); scpClient.Disconnect();