Since SSH protocol specification defines that server
should have (unique) key (public and private pair) that is
sent to the client and is used to encrypt communication,
wodSSHD has one internal object that deals with the keys.
This property holds a reference to such object.
There is only one key necessary to have the server
properly running - either RSA type
key, or DSA. RSA is defined as a standard, and by
specification all clients should support it. Before server
is started, you should make sure you have properly
generated new pair of keys (or loaded old one using
provided functions). However, to allow more clients to
access you server you should generate both RSA and DSA keys.
Important thing is to try to keep the same key as long
as you can (or need to). Since clients that connect always
check if key you're using is the same one last time was
used (this way they know whether they connected to the same
server), changing it often can produce problems to the
clients. Also, when client connects for the first time and
wants to make sure it connected to the server he intended
to, he can check Fingerprint
information he got with the one you will provide him
through Fingerprint
property.
Creating new keys is really easy. This little code
snippet can be used in your projects so you can be sure
there's always proper key is loaded.
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 to do so 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
' and save it for the
future
wodSSHD1.Keys.Save RSAkey, Filename, Password
End If
' now the server can be
started...
End Sub