- Principle
- How to?
- Direct sending of commands
- Dialog with an SSH server
Communicating with an SSH server
Secure Shell (SSH) is a secure communication protocol. The exchanged data is secured via encryption keys. A server can support the secure SSH protocol to receive remote commands. WINDEV and WEBDEV propose several functions allowing you to connect, start a session, transmit commands to run and retrieve the result of these commands. The protocol is SSH-2. Two methods can be used to communicate with an SSH server: Direct sending of commands The direct sending of commands is performed by SSHCommand. The parameters for connecting to the SSH server must be described in an sshSession variable. Example:
cMySession is sshSession buffOutput is Buffer cMySession.Address = "127.0.0.1" cMySession.Port = 22 cMySession.User = "login" cMySession.UserPassword = "pass" nExitCode is int sOutput is ANSI string sOutputErr is ANSI string (nExitCode, sOutput, sOutputErr) = SSHCommand(cMySession, EDT_Command) IF ErrorOccurred THEN Error(ErrorInfo(errFullDetails)) RETURN END EDT_ExitCode = nExitCode EDT_StdOut = UTF8ToString(sOutput) EDT_StdErr = UTF8ToString(sOutputErr)
Dialog with an SSH server The dialog with the SSH server is performed by the following functions:
The parameters for connecting to the SSH server must be described in an sshSession variable. Example:
cMySession is sshSession cMySession.Address = "127.0.0.1" cMySession.Port = 22 cMySession.User = "login" cMySession.UserPassword = "pass" IF SSHConnectShell(cMySession) THEN Info("Session started") bufOutput is Buffer = "data" SSHWrite(cMySession, bufOutput) SSHDisconnectShell(cMySession) END
This page is also available for…
|
|
|
|