I’m looking to ssh non-interactively into a service on my balenaOS host.
From SSH access - Balena Documentation
Note: To run a command in a non-interactive way, you can pipe commands to the CLI’s stdin. For example,
echo "uptime; exit;" | balena ssh <device-uuid>
.
This works well for running commands on the Host, but I can’t figure how to format it in such a way that my commands are piped into a running service. I tried piping to balena ssh <device-uuid> <service>
but it doesn’t return anything. I also tried writing a testfile in the remote command but the file was not created.
$ echo "uptime; exit;" | balena ssh <device-uuid>
[debug] original argv0="balena" argv=[/usr/local/balena-cli/balena,/snapshot/versioned-source/bin/balena,ssh,<device-uuid>] length=4
[Debug] Fetching application by name <device-uuid> (string)
[Debug] Application not found
[Debug] Fetching device by UUID <device-uuid> (string)
=============================================================
Welcome to balenaOS
=============================================================
16:37:07 up 17:17, 1 user, load average: 0.33, 0.50, 0.50
$ echo "uptime; exit;" | balena ssh <device-uuid> <service>
[debug] original argv0="balena" argv=[/usr/local/balena-cli/balena,/snapshot/versioned-source/bin/balena,ssh,<device-uuid>,mariadb] length=5
[Debug] Fetching application by name <device-uuid> (string)
[Debug] Application not found
[Debug] Fetching device by UUID <device-uuid> (string)
I tried adding --verbose
and enabling DEBUG=1
but it didn’t return anything useful that I could find.
# environment
$ lsb_release -a
Distributor ID: elementary
Description: elementary OS 5.1.4 Hera
Release: 5.1.4
Codename: hera
$ uname -a
Linux <hostname> 5.3.0-51-generic #44~18.04.2-Ubuntu SMP Thu Apr 23 14:27:18 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$ balena -v
11.29.3
$ balena device <device-uuid>
== SILENT MOUNTAIN
ID: 2006664
DEVICE TYPE: raspberrypi3-64
STATUS: idle
IS ONLINE: true
IP ADDRESS: 192.168.8.9
APPLICATION NAME: nextcloud
UUID: <device-uuid>
COMMIT: 43865036494c0ed0073ea8e958823561e519f842
SUPERVISOR VERSION: 10.6.27
IS WEB ACCESSIBLE: false
OS VERSION: balenaOS 2.47.0+rev1
DASHBOARD URL: https://dashboard.balena-cloud.com/devices/<device-uuid>/summary