Run a command over resin ssh and exit / push file to device


using ssh I could

ssh -t user@server "<cmd>"

to run a cmd on server without typing it in the remote shell.
Is there a way to do that with resin ssh. (without installing a sshd in a user container)

What I want to do is trigger a scp command to pull a file into the device.
Maybe there is a better way to do that…? We need to add some project specific files to the device before shipping. The devices are preloaded (resin preload)


@seb welcome to the forums!

I don’t think there’s currently a way to do this with resin ssh but I am sure one of my colleagues will correct me if there is!

Is there a reason why you couldn’t pull the files to the device as part of your container setup? Although you have preloaded, the devices will update to the latest version when they connect if there’s one available. Or are you trying to add files to the host? If you could explain your scenario in a bit more detail we’ll try and help with a solution.


The files I want to push are project (==device) specific. The device is a Gateway to the KNX bus. It provides a visualisation of the connected KNX datapoints. These datapoints differ from device to device .
So I’d like to take one of the preloaded devices and add the device specific stuff in one short step by running a script.


OK so this definitely is not supported by resin ssh at this time but it is something that has been requested by a number of users; so it is on the radar although I can’t give an ETA. I have added this thread to our internal notes for this feature request.

In the meantime I personally would be trying to approach it from the other side. What about setting a device variable that identifies your device with the device specific stuff you mention, then adding a generic script to the container to read that variable and automatically pull your files from whatever source you have?


its good to know, that this is on your radar. Is this already on the public roadmap?

Do you also consider, that it would be helpful for this to have a param for resin local scan to just get the device ID of a single connected device? So instead of

$ sudo resin local scan | grep host: | sed 's/host: *\(.*\)\.local/\1/g'

I could do

$ sudo resin local scan --short

So in combination with an resin scp - or whatever you will create - I could write a simple script to do the provisioning like this:

# only works if scan finds only one device
DEVICE_ID = "$(sudo resin local scan --short)"
# here I've invented resin scp which takes a container name in addition to target path
resin scp my_config.json ${DEVICE_ID}:my_container_name/my_target_dir
# this already exists
resin env add MY_ENV_VAR value --device ${DEVICE_ID}

Having something like this would be very handy.

In the meantime I’ll add a sshd to the user container that needs the data.

thanks for your help.


It’s not on the public roadmap as far as I can see but it is logged on our internal balena issue tracker with the other threads that mention it so it won’t be lost!

Hopefully installing sshd works OK for you in the meantime. :+1: