Back to product page
- Introduction
- Overview
- License agreement
- Getting Started
- Objects
- Enumerations
- wodSSHD
- Methods
- Properties
- Events
- Connecting
- CryptoInformation
- Disconnected
- LoginGSSAPI
- LoginPassword
- LoginPubkey
- PortBindRequest
- PortForwardConnect
- PortForwardDisconnect
- PortForwardRequest
- Received
- ServiceRequest
- ServiceStart
- SftpDeleteFile
- SftpDownloadFile
- SftpFileTransferData
- SftpListDir
- SftpListDirData
- SftpMakeDir
- SftpProgress
- SftpRemoveDir
- SftpRename
- SftpTransferComplete
- SftpUploadFile
- StateChanged
- IwodSSHDNotify
- Methods
- Connecting
- CryptoInformation
- Disconnected
- LoginGSSAPI
- LoginPassword
- LoginPubkey
- PortBindRequest
- PortForwardConnect
- PortForwardDisconnect
- PortForwardRequest
- Received
- ServiceRequest
- ServiceStart
- SftpDeleteFile
- SftpDownloadFile
- SftpFileTransferData
- SftpListDir
- SftpListDirData
- SftpMakeDir
- SftpProgress
- SftpRemoveDir
- SftpRename
- SftpTransferComplete
- SftpUploadFile
- StateChanged
- Methods
- SSHKeyPair
- SSHUser
- SSHUsers
- How to get support
- Technical information
- Fast notifications
- Error list
Generate
Generate new pair of keys.
Type
NoneSyntax
- Basic
object.Generate KeyType, (BitCount)
The Generate(object,KeyTyple,BitCount) syntax has these parts:
The Generate(object,KeyTyple,BitCount) syntax has these parts:
object | An expression evaluating to an object of type SSHKeyPair. |
KeyTyple | Required. A SSHKeyTypes enumeration, as described in settings. Type of the key (RSA, DSA or ECDSA). |
BitCount | Optional. A Variant value. Number of bits in generated key. |
Remarks
Generate method should be called when you need to generate new key to be used with the server. KeyType should be set either 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.
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, and the server, of course. To help you accomplish this, storing generated keys can optionally be protected using a Password in Save method. Typical scenario to deal with generating/loading/saving keys would be something like this (sample in VB):
Private Sub Form_Load()
Dim Filename As String
Dim Password As String
' initialize wodSSHD
Set wodSSHD1 = New wodSSHDCom
' first we need to load or generate key we will use
' in productional systems, generate both keys (RSA/DSA)
' here, just for the sample, one is enough.
On Error Resume Next
Filename = App.Path + "\mykey.rsa"
' we don't need to put password at all - but it's better in real life
Password = "My secret password"
' try to load the key
wodSSHD1.Keys.Load Filename, Password
If Err <> 0 Then
' load failed - we will generate new one
wodSSHD1.Keys.Generate RSAkey
wodSSHD1.Keys.Save RSAkey, Filename, Password
End If
' now you can start the server
End Sub
Code sample
- Basic
Private Sub Form_Load()
Dim Filename As String
Dim Password As String
' initialize wodSSHD
Set wodSSHD1 = New wodSSHDCom
' first we need to load or generate key we will use
' in productional systems, generate both keys (RSA/DSA)
' here, just for the sample, one is enough.
On Error Resume Next
Filename = App.Path + "\mykey.rsa"
' we don't need to put password at all - but it's better in real life
Password = "My secret password"
' try to load the key
wodSSHD1.Keys.Load Filename, Password
If Err <> 0 Then
' load failed - we will generate new one
wodSSHD1.Keys.Generate RSAkey
wodSSHD1.Keys.Save RSAkey, Filename, Password
End If
' now you can start the server
End Sub
Dim Filename As String
Dim Password As String
' initialize wodSSHD
Set wodSSHD1 = New wodSSHDCom
' first we need to load or generate key we will use
' in productional systems, generate both keys (RSA/DSA)
' here, just for the sample, one is enough.
On Error Resume Next
Filename = App.Path + "\mykey.rsa"
' we don't need to put password at all - but it's better in real life
Password = "My secret password"
' try to load the key
wodSSHD1.Keys.Load Filename, Password
If Err <> 0 Then
' load failed - we will generate new one
wodSSHD1.Keys.Generate RSAkey
wodSSHD1.Keys.Save RSAkey, Filename, Password
End If
' now you can start the server
End Sub