<PackageReference Include="SSH.NET" Version="2016.0.0-beta3" />

ServiceFactory

Basic factory for creating new services.
using Renci.SshNet.Common; using Renci.SshNet.Messages.Transport; using Renci.SshNet.NetConf; using Renci.SshNet.Security; using Renci.SshNet.Sftp; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Renci.SshNet { internal class ServiceFactory : IServiceFactory { public IClientAuthentication CreateClientAuthentication() { return new ClientAuthentication(); } public ISession CreateSession(ConnectionInfo connectionInfo) { return new Session(connectionInfo, this); } public ISftpSession CreateSftpSession(ISession session, TimeSpan operationTimeout, Encoding encoding) { return new SftpSession(session, operationTimeout, encoding); } public PipeStream CreatePipeStream() { return new PipeStream(); } public IKeyExchange CreateKeyExchange(IDictionary<string, Type> clientAlgorithms, string[] serverAlgorithms) { if (clientAlgorithms == null) throw new ArgumentNullException("clientAlgorithms"); if (serverAlgorithms == null) throw new ArgumentNullException("serverAlgorithms"); Type type = (from c in clientAlgorithms from s in serverAlgorithms where s == c.Key select c.Value).FirstOrDefault(); if ((object)type == null) throw new SshConnectionException("Failed to negotiate key exchange algorithm.", DisconnectReason.KeyExchangeFailed); return type.CreateInstance<IKeyExchange>(); } public INetConfSession CreateNetConfSession(ISession session, TimeSpan operationTimeout) { return new NetConfSession(session, operationTimeout); } } }