Class PrivateKeyFile | SSH.NET - A Secure Shell (SSH) library for .NET, optimized for parallelism (original) (raw)
Namespace
Assembly
Renci.SshNet.dll
Represents private key information.
public class PrivateKeyFile : IPrivateKeySource, IDisposableInheritance
Implements
Inherited Members
Remarks
The following private keys are supported:
- RSA in OpenSSL PEM, ssh.com, OpenSSH and PuTTY key format
- ECDSA 256/384/521 in OpenSSL PEM, OpenSSH and PuTTY key format
- ED25519 in OpenSSL PEM, OpenSSH and PuTTY key format
The following encryption algorithms are supported for OpenSSL traditional PEM:
- DES-EDE3-CBC
- DES-EDE3-CFB
- AES-128-CBC
- AES-192-CBC
- AES-256-CBC
Private keys in OpenSSL PKCS#8 PEM format can be encrypted using any cipher method BouncyCastle supports.
The following encryption algorithms are supported for ssh.com format:
- 3des-cbc
The following encryption algorithms are supported for OpenSSH key format:
- 3des-cbc
- aes128-cbc
- aes192-cbc
- aes256-cbc
- aes128-ctr
- aes192-ctr
- aes256-ctr
- aes128-gcm@openssh.com
- aes256-gcm@openssh.com
- chacha20-poly1305@openssh.com
The following encryption algorithms are supported for PuTTY key format:
- aes256-cbc
Constructors
PrivateKeyFile(Key)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(Key key)Parameters
key Key
The key.
PrivateKeyFile(Stream)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(Stream privateKey)Parameters
privateKey Stream
The private key.
PrivateKeyFile(string)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(string fileName)Parameters
fileName string
The path of the private key file.
Remarks
This method calls System.IO.File.Open(System.String,System.IO.FileMode) internally, this method does not catch exceptions from System.IO.File.Open(System.String,System.IO.FileMode).
Exceptions
fileName is null.
PrivateKeyFile(string, string?)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(string fileName, string? passPhrase)Parameters
fileName string
The path of the private key file.
passPhrase string?
The pass phrase for the private key.
Remarks
This method calls System.IO.File.Open(System.String,System.IO.FileMode) internally, this method does not catch exceptions from System.IO.File.Open(System.String,System.IO.FileMode).
Exceptions
fileName is null.
PrivateKeyFile(string, string?, string?)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(string fileName, string? passPhrase, string? certificateFileName)Parameters
fileName string
The path of the private key file.
passPhrase string?
The pass phrase for the private key.
certificateFileName string?
The path of a certificate file which certifies the private key.
Exceptions
fileName is null.
PrivateKeyFile(Stream, string?)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(Stream privateKey, string? passPhrase)Parameters
privateKey Stream
The private key.
passPhrase string?
The pass phrase.
Exceptions
privateKey is null.
PrivateKeyFile(Stream, string?, Stream?)
Initializes a new instance of the Renci.SshNet.PrivateKeyFile class.
public PrivateKeyFile(Stream privateKey, string? passPhrase, Stream? certificate)Parameters
privateKey Stream
The private key.
passPhrase string?
The pass phrase for the private key.
certificate Stream?
A certificate which certifies the private key.
Properties
Certificate
Gets the public key certificate associated with this key, or null if no certificate data has been passed to the constructor.
public Certificate? Certificate { get; }Property Value
HostKeyAlgorithms
Gets the supported host algorithms for this key file.
public IReadOnlyCollection<HostAlgorithm> HostKeyAlgorithms { get; }Property Value
IReadOnlyCollection<HostAlgorithm>
Key
Gets the key.
public Key Key { get; }Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)Parameters
disposing bool
true to release both managed and unmanaged resources; false to release only unmanaged resources.