Back to product page

Generate method

Generate new pair of keys.




  • Basic
object.Generate KeyType, [BitCount]
The Generate(object,KeyType,BitCount) syntax has these parts:
objectAn expression evaluating to an object of type Keys.
KeyTypeRequired. A SSHKeyTypes enumeration, as described in settings. Type of the key.
BitCountOptional. A Variant value. Specifies total number of bits in generated key (defaults to 1024).


The settings for KeyType are:

Constant Value Description
RSAkey 0 Uses RSA algorithm to create keys.
DSAkey 1 Uses DSA algorithm to create keys.
ECDSAkey 2 Uses ECDSA algorithm to create keys.

Generate method should be called when you need to generate new key to be used with the server. KeyType should be set to RSAkey, DSAkey or ECDSAkey. Old (if any) key loaded in memory will be destroyed, and new one will take it's place. It is advised that immediately after new key is generated, you should Save it to a file for future use.

Generate method can be a lengthy process, especially if you set large BitCount value (default BitCount is 1024). It is advised you make random mouse movements, or type on the keyboard during the keys generation, to get more random values for new keys. Possible bitcount values for generating new keys are 768, 1024 (default), 2048 and 3072 (for RSA and DSA), and 256, 384 and 521 for ECDSA key.

If you with to transfer your existing keys from OpenSSH (or similar) SSH server, you can easily load such keys using Load method. In such case there is no need to generate new pair of keys.

Important thing is to keep the key private and unreadable by anyone else except yourself. To help you accomplish this, storing generated keys can optionally be protected using a Password in Save method.

Code sample

  • Basic