upload new png to device using ssh connection

Hello. I am wondering if it is possible to connect to a device using SSH and then upload a file to the hostOS. I would like to provide a different file for the balena-logo.png file so something else is displayed on the screen. We are using a Raspberry pi CM4 within a display. I am able to replace the file by accessing the the boot folder via bootmode, but would like to be able to replace over the network. I would then like to know how to initialize the new splash media without rebooting. Is there a command to do this? Thanks

Hi @tdickson,

The standard ssh, scp and rsync tools can be used with balenaOS devices. It works with both development and production balenaOS images. In the case of a production image, a ssh key should be added to the config.json file – see sshKeys section of the meta-balena README file. In the case of a development image, no keys are required. (Development images allow root login without a password or ssh keys, so should never be directly exposed to the public internet.)

The ssh server on a device (host OS) listens on TCP port number 22222. This port is not blocked by the device host OS, not even in production. If this port is blocked by a firewall or router on the device’s local network, or if the device has a private IP address, the balena tunnel command can be used as in the examples below.

Example 1 (port 22222 not blocked in the device’s local network, and the device has a public / globally routable IPv4/v6 address)

# All these commands to be executed on your laptop/desktop
$ ssh -p 22222 root@<device_ip_address>
$ scp -P 22222 my_local_file root@<device_ip_address>:/mnt/data/
$ export RSYNC_RSH='ssh -p 22222'
$ rsync my_local_file root@<device_ip_address>:/mnt/data/

Example 2 (port 22222 is blocked in the device’s local network, or private IP address)

# All these commands to be executed on your laptop/desktop
$ balena tunnel <deviceUUID> -p 22222:4321
$ ssh -p 4321 root@127.0.0.1
$ scp -P 4321 my_local_file root@127.0.0.1:/mnt/data/
$ export RSYNC_RSH='ssh -p 4321'
$ rsync my_local_file root@127.0.0.1:/mnt/data/

Note that the UUID argument for the balena tunnel commands should be the “long UUID”, not the “short UUID”. Using the “short UUID” may result in some counter-intuitive errors.

Let us know if this works for your use case, thanks!

Regards,
Christina