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
First steps with wodSSHServer
For setting up wodSSHServer you should follow below steps. Before each step we will try to explain why are we doing it.
Before we can use wodSSHServer, we must add it to our program, or at least add reference to it. In Visual Basic, you should click on 'Project' and then on 'Component' and find 'WeOnlyDo! wodSSHServer Suite ActiveX Control' and add it to the list of all referenced components. If you plan to use DLL version of the component, then click on 'Project' and then on 'References', find 'WeOnlyDo! wodSSHServer Suite COM Object' and include it into the project.
1. Put wodSSHServer ActiveX on the form
-
- if you are using wodSSHServer.DLL, then you should declare wodSSHServer like this:
Dim WithEvents wodSSHServer1 as wodSSHDCom
and then in Form_Load you should do
Set wodSSHServer1 = new wodSSHDCom
2. Add code to generate private keys needed for SSH protocol (only applies if you plan to use SSH protocol!)
Now we will generate private keys (and derive public ones from them) which will be needed to represent ourselves to the clients. wodSSHServer DOES NOT work if keys are not generated, because they are important part of SSH protocol specification. You should, usually, generate two keys: DSA and RSA keys. Different clients support different key types, so we will support both of them. Now, when client connects he may choose which one he will use to determine if server is not fake one. Best place to do this is Form_Load event.Private Sub Form_Load()
Dim Filename As String
' 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"
' try to load the key
wodSSHServer1.Keys.Load Filename
If Err <> 0 Then
' load failed - we will generate new one
wodSSHServer1.Keys.Generate RSAkey
wodSSHServer1.Keys.Save RSAkey, Filename
End If
' now start the server
wodSSHServer1.Start
End Sub
3. Add code to handle user authentication
By default, wodSSHServer will reject all logins, so we need to add some code that will handle authentication of users. We will do this in LoginPassword event. Simply, we will allow only user 'joe' with password 'joe' to gain access to the system. All other users will be rejected. We could, also, check User.Hostname property to determine where is he coming from - and if it's not from some trusted IP address, we could also deny access.Private Sub SSHD1_LoginPassword(ByVal User As wodSSHDComLIB.ISSHUser, ByVal Login As String, ByVal Password As String, Action As wodSSHDComLIB.SSHActions)
If Login = "joe" And Password = "joe" Then
Action = Allow
Else
Action = Deny
End If
End Sub
Private Sub wodSSHD1_LoginPubkey(ByVal User As wodSSHDComLIB.ISSHUser, ByVal Login As String, ByVal PublicKey As String, Action As wodSSHDComLIB.SSHActions)
If Login = "joe" And PublicKey = "ssh-rsa AAAAB3NzaC1.....A5dxuzFobhu+m1xgv8=" Then
Action = Allow
End If
End Sub
4. Determine which service user requests
Once user is authenticated with the server, he will request to run certain service on wodSSHServer. Most commonly, this is execution of shell (command prompt), but can also be execution of some file on your system, running SFTP server to transfer files, open port forwarding etc.. When user requests to start new service (and this can happen at any time), ServiceRequest event is fired with information about service type. You should here decide whether you will allow user to run specific service, or change service type. For example, you can 'fool' the user and instead of spawning a shell, you can return some custom data to the user - he will not know the difference. This is what we will do in this sample:Private Sub wodSSHServer1_ServiceRequest(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ServiceType As wodSSHDComLIB.SSHServiceTypes, ServicePath As String, Action As wodSSHDComLIB.SSHActions)
' don't execute anything - we'll have a small chat
ServiceType = stNone
End Sub