Skip to content

TFTP & SCP

Use TFTP or SCP when you need to pull a config file, firmware image, or log off a device — or push one to it.

D.device.scp.upload sends a local file to the device; D.device.scp.download fetches one from the device. SCP rides on SSH so credentials are the same as the SSH guide.

D.device.scp.download({
remote_path: '/etc/config.txt',
local_path: '/tmp/device-config.txt',
username: 'admin',
password: 'secret',
port: 22,
timeout: 10000
}, function (error) {
if (error) return D.failure(D.errorType.RESOURCE_UNAVAILABLE);
// file is now at /tmp/device-config.txt on the collector host
});
D.device.scp.upload({
local_path: '/tmp/new-config.txt',
remote_path: '/etc/config.txt',
username: 'admin',
password: 'secret'
}, function (error) {
if (error) return D.failure(D.errorType.RESOURCE_UNAVAILABLE);
});

TFTP is connectionless and unauthenticated. Drivers get both a client and a server, so you can either pull from a device that only exposes TFTP, or stand up a short-lived TFTP target for devices that push firmware.

D.device.tftpClient.download({
remote_path: '/running-config',
local_path: '/tmp/running-config',
port: 69,
timeout: 10000
}, function (error) {
if (error) return D.failure(D.errorType.RESOURCE_UNAVAILABLE);
});
D.device.tftpClient.upload({
local_path: '/tmp/firmware.bin',
remote_path: '/firmware.bin'
}, function (error) {
if (error) return D.failure(D.errorType.RESOURCE_UNAVAILABLE);
});
D.tftpServer.serve({
root: '/tmp',
port: 6969,
timeout: 60000
}, function (error) {
if (error) return D.failure(D.errorType.GENERIC_ERROR);
});

When the server mode is active the collector listens on port, serves files under root, and stops after timeout ms of inactivity. Useful when the device pushes instead of pulls.

local_path is a path on the collector host filesystem, which is the Domotz Collector machine — not your development machine. Paths under /tmp are reliable. Anything else depends on the collector’s deploy environment.

remote_path is the path on the device. For many networking devices this is not a real filesystem path — it’s a logical name the device recognises (for example Cisco’s running-config). Consult the device’s vendor docs.

D.device.scp.download({ ... }, function (error) {
if (error) {
if (error.code === 'AUTHENTICATION_FAILED') return D.failure(D.errorType.AUTHENTICATION_ERROR);
if (error.code === 'ENOENT') return D.failure(D.errorType.PARSING_ERROR);
return D.failure(D.errorType.RESOURCE_UNAVAILABLE);
}
});