diff --git a/README.md b/README.md index e0226726..3e4e00f7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ using Microsoft.Extensions.Logging; using Tmds.Ssh; using ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); -using var sshClient = new SshClient("localhost", loggerFactory); +using var sshClient = new SshClient("localhost", SshConfigSettings.DefaultConfig, loggerFactory); using var process = await sshClient.ExecuteAsync("echo 'hello world!'"); (bool isError, string? line) = await process.ReadLineAsync(); Console.WriteLine(line); @@ -55,8 +55,11 @@ namespace Tmds.Ssh; class SshClient : IDisposable { - SshClient(string destination, ILoggerFactory? loggerFactory = null); // uses SshConfigSettings.DefaultConfig. + // Connect to the destination. No additional config. + SshClient(string destination, ILoggerFactory? loggerFactory = null); + // Use OpenSSH config files and options to configure the client. SshClient(string destination, SshConfigSettings configSettings, ILoggerFactory? loggerFactory = null); + // Use the .NET SshClientSettings API to configure the client. SshClient(SshClientSettings settings, ILoggerFactory? loggerFactory = null); // Calling ConnectAsync is optional when SshClientSettings.AutoConnect is set (default). @@ -119,6 +122,7 @@ class SftpClient : IDisposable const UnixFilePermissions DefaultCreateFilePermissions; // = '-rwxrwxrwx'. // The SftpClient owns the connection. + SftpClient(string destination, ILoggerFactory? loggerFactory = null, SftpClientOptions? options = null); SftpClient(string destination, SshConfigSettings configSettings, ILoggerFactory? loggerFactory = null, SftpClientOptions? options = null); SftpClient(SshClientSettings settings, ILoggerFactory? loggerFactory = null, SftpClientOptions? options = null); diff --git a/examples/scp/Program.cs b/examples/scp/Program.cs index fc327b55..983794f8 100644 --- a/examples/scp/Program.cs +++ b/examples/scp/Program.cs @@ -22,7 +22,7 @@ string sshDestination = source.SshDestination ?? destination.SshDestination!; -using SshClient client = new SshClient(sshDestination); +using SshClient client = new SshClient(sshDestination, SshConfigSettings.DefaultConfig); await client.ConnectAsync(); diff --git a/src/Tmds.Ssh/SftpClient.cs b/src/Tmds.Ssh/SftpClient.cs index 407793a6..97e03579 100644 --- a/src/Tmds.Ssh/SftpClient.cs +++ b/src/Tmds.Ssh/SftpClient.cs @@ -49,6 +49,10 @@ enum State internal SshClient SshClient => _client; internal bool IsDisposed => _state == State.Disposed; + public SftpClient(string destination, ILoggerFactory? loggerFactory = null, SftpClientOptions? options = null) : + this(destination, SshConfigSettings.NoConfig, loggerFactory, options) + { } + public SftpClient(string destination, SshConfigSettings configSettings, ILoggerFactory? loggerFactory = null, SftpClientOptions? options = null) : this(new SshClient(destination, configSettings, loggerFactory), options, ownsClient: true) { } diff --git a/src/Tmds.Ssh/SshClient.cs b/src/Tmds.Ssh/SshClient.cs index 7027d303..cabc3d37 100644 --- a/src/Tmds.Ssh/SshClient.cs +++ b/src/Tmds.Ssh/SshClient.cs @@ -36,7 +36,7 @@ enum State internal bool IsDisposed => _state == State.Disposed; public SshClient(string destination, ILoggerFactory? loggerFactory = null) : - this(destination, SshConfigSettings.DefaultConfig, loggerFactory) + this(destination, SshConfigSettings.NoConfig, loggerFactory) { } public SshClient(SshClientSettings settings, ILoggerFactory? loggerFactory = null) : diff --git a/src/Tmds.Ssh/SshConfigOptions.cs b/src/Tmds.Ssh/SshConfigSettings.cs similarity index 100% rename from src/Tmds.Ssh/SshConfigOptions.cs rename to src/Tmds.Ssh/SshConfigSettings.cs