Initializes a new instance of the SshClient class.
Namespace: Renci.SshNetAssembly: Renci.SshNet (in Renci.SshNet.dll) Version: 0.1.0.0 (1.0.0.0)
Syntax
public SshClient( ConnectionInfo connectionInfo )
Parameters
- connectionInfo
- Type: Renci.SshNet ConnectionInfo
The connection info.
Exceptions
| Exception | Condition |
|---|---|
| connectionInfo is null. |
Examples
var connectionInfo = new PasswordConnectionInfo(host, username, password); using (var client = new SftpClient(connectionInfo)) { client.Connect(); // Do something here client.Disconnect(); }
var connectionInfo = new PasswordConnectionInfo("host", "username", "password"); var encoding = new Renci.SshNet.Common.ASCIIEncoding(); connectionInfo.PasswordExpired += delegate(object sender, AuthenticationPasswordChangeEventArgs e) { e.NewPassword = encoding.GetBytes("123456"); }; using (var client = new SshClient(connectionInfo)) { client.Connect(); client.Disconnect(); }
var connectionInfo = new PrivateKeyConnectionInfo(host, username, new PrivateKeyFile(keyFileStream)); using (var client = new SshClient(connectionInfo)) { client.Connect(); client.Disconnect(); }
var connectionInfo = new PasswordConnectionInfo(host, username, password); connectionInfo.Timeout = TimeSpan.FromSeconds(30); using (var client = new SshClient(connectionInfo)) { client.Connect(); // Do something here client.Disconnect(); }
See Also