SSH & SCP
Run commands over SSH and move files with SCP.
See SSH driver examples on GitHub.
D.device.scp.download
Section titled “D.device.scp.download”Retrieves a file content from a remote server using SCP.
Signature
D.device.scp.download(options, callback)Parameters
options· `scpDownloadOptions`- The SCP download execution options
options.filePath· `string`- The source file path on the device. It defines the location of the file to be downloaded.
options.port· `string` · optional, default `22`- The SCP port
options.timeout· `int` · optional- The time to wait for the scp download command execution
options.username· `string` · optional- The device username. If not set the custom driver management purpose one is used
options.password· `string` · optional- The device password. If not set the custom driver management purpose one is used
callback· `callback`- The SCP upload execution callback
callback.output· `object`- The stdout from the scp upload command execution
callback.output.content· `string` · optional- The content of file downloaded from the device, if the execution did not result in an error
callback.output.stdout· `string`- The stdout from the scp download command execution
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.scp.download(options, callback)D.device.scp.upload
Section titled “D.device.scp.upload”Transfers a file content to a remote server using SCP.
Signature
D.device.scp.upload(options, callback)Parameters
options· `object`- The SCP upload execution options
options.filePath· `string`- The destination file path on the device. It defines where the content will be stored
options.content· `string`- The content of the file to be stored on the device
options.port· `string` · optional, default `22`- The SCP port
options.timeout· `int` · optional- The time to wait for the scp upload command execution
options.username· `string` · optional- The device username. If not set the custom driver management purpose one is used
options.password· `string` · optional- The device password. If not set the custom driver management purpose one is used
callback· `callback`- The SCP upload execution callback
callback.output· `string`- The stdout from the scp upload command execution
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.scp.upload(options, callback)D.device.sendSSHCommand
Section titled “D.device.sendSSHCommand”Sends a command to the device via SSH.
Signature
D.device.sendSSHCommand(options, callback)Parameters
options· `Object`- The SSH Command execution options
options.command· `string`- The ssh command to execute against the device
options.timeout· `int` · optional- The time to wait for the command execution
options.username· `string` · optional- The device username. If not set the custom driver management purpose one is used
options.password· `string` · optional- The device password. If not set the custom driver management purpose one is used
options.keyboard_interactive· `boolean` · optional- Try keyboard-interactive user authentication if primary user authentication method fails
options.port· `string` · optional, default `22`- The SSH port
options.algorithms· `SshAlgorithms` · optional- The SSH Kex and Ciphers to use * @example // Some available cipher and kex
callback· `function`- The SSH Command execution callback function
callback.output· `string`- The stdout from the SSH Command execution
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.sendSSHCommand(options, callback)D.device.sendSSHCommands
Section titled “D.device.sendSSHCommands”Sends a sequence of commands to the device via SSH.
Signature
D.device.sendSSHCommands(options, callback)Parameters
options· `Object`- The SSH Commands execution options
options.commands· `Array.` - The ssh commands to execute against the device
options.username· `string` · optional- The device username. If not set the custom driver management purpose one is used
options.password· `string` · optional- The device password. If not set the custom driver management purpose one is used
options.keyboard_interactive· `boolean` · optional- Try keyboard-interactive user authentication if primary user authentication method fails*
options.prompt· `string` · optional, default `#`- The device ssh prompt expected. If not set correctly it may result in a timeout
options.prompt_regex· `string` · optional- The device ssh prompt regular expression expected. Used if a device prompt changes during ssh sequence execution
options.error_prompt· `string` · optional- The device error prompt expected. Used when there is an expected error prompt string to halt the execution
options.inter_command_timeout_ms· `int` · optional, default `1000`- Timeout to wait between ssh sequence commands executions
options.global_timeout_ms· `int` · optional, default `30000`- The global ssh shell sequence execution timeout. When expired results in TIMEOUT_ERROR
options.port· `string` · optional, default `22`- The SSH port
options.algorithms· `SshAlgorithms` · optional- The SSH Kex and Ciphers to use
callback· `function`- The SSH Commands execution callback function
callback.outputs· `Array.` - The output list of the SSH Commands executions
callback.error· `ErrorResult` · optional- Will be present if the execution resulted in an error
Returns
void
Example
D.device.sendSSHCommands(options, callback)