SshClient Constructor (ConnectionInfo)SSH .NET Client Library Documentation
Initializes a new instance of the SshClient class.

Namespace: Renci.SshNet
Assembly: Renci.SshNet (in Renci.SshNet.dll) Version: 0.1.0.0 (1.0.0.0)
Syntax

public SshClient(
	ConnectionInfo connectionInfo
)
Exceptions

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