This is an old revision of the document!
SessionOptions Class
Defines information to allow an automatic connection and authentication of the session. Is used with Session.Open method. 
This feature will be available only with the next release.
Syntax
Namespace: WinSCP
Advertisement
public sealed class SessionOptions
Constructors
| Name | Description | 
|---|---|
| SessionOptions() | Default constructor. | 
Properties
| Name | Description | 
|---|---|
| string HostKey | Host key of the SSH server. Mandatory for SFTP/SCP protocol. | 
| string HostName | Name of the host to connect to. Mandatory property. | 
| string Password | Password for authentication. | 
| int PortNumber | Port number to connect to. Keep default 0to use the default port for the protocol. | 
| SessionProtocols Protocol | Protocol to use for the session. Possible values are SessionProtocols.Sftp(default),SessionProtocols.ScpandSessionProtocols.Ftp. | 
| string UserName | Username for authentication. Mandatory property. | 
Remarks
You need to fill in all properties required to connect and authenticate your session automatically.
Advertisement
You always need to fill in Protocol, HostName and UserName1.
In most cases you need to fill in Password. Exceptions are:
- You use different authentication method than a password authentication, such as public key authetication (with passphrase-less private key or with use of Pageant) for SSH session;
- The server does not require password.
For SSH (SFTP/SCP) session you need to fill in the HostKey to verify the expected server host key.
- Except for very rare occasions that the server does not require username.Back