balena ssh acting in a confusing way

I think I have a basic gap in my understanding. It seems that when I ssh into my balena device I am being put into the balena supervisor (not sure of the topic) so there’s no /ros directory, but when I do ssh from the web site I am put into my app. But I don’t understand why or what I am doing wrong. Maybe you can help?

Here are some transcripts:

ID      UUID    DEVICE NAME    DEVICE TYPE     APPLICATION NAME STATUS IS ONLINE SUPERVISOR VERSION OS VERSION           DASHBOARD URL
3815766 dd641d8 lingering-bush raspberrypi3-64 gopigo3          Idle   true      10.6.27            balenaOS 2.47.0+rev1 https://dashboard.balena-cloud.com/devices/dd641d8fd65c20db1b11ff990c762218/summary
~/m/Balena-ROS-Melodic (gopigo3=)

~/m/Balena-ROS-Melodic (gopigo3=) balena apps
ID      APP NAME SLUG                 DEVICE TYPE     ONLINE DEVICES DEVICE COUNT
1707375 gopigo3  gh_pitosalas/gopigo3 raspberrypi3-64 1              1
~/m/Balena-ROS-Melodic (gopigo3=)

From the web based console log for ssh:

Connecting to dd641d8fd65c20db1b11ff990c762218...
Spawning shell...
root@gopigo3:/ros/catkin_ws# ls
build  devel  src
root@gopigo3:/ros/catkin_ws# 

And

~/m/Balena-ROS-Melodic (gopigo3=) balena ssh dd641d8
=============================================================
    Welcome to balenaOS
=============================================================
root@gopigo3:~# ls
root@gopigo3:~# ls -la
total 4
drwx------ 4 root root 1024 Feb  3 18:39 .
drwxr-xr-x 3 root root 1024 Jan 31 07:59 ..
lrwxrwxrwx 1 root root    7 Jan 31 09:23 .balena -> .docker
lrwxrwxrwx 1 root root    7 Jan 31 09:23 .balena-engine -> .docker
drwxr-xr-x 2 root root 1024 Jan 31 09:21 .docker
-rw-r--r-- 1 root root    0 Jan 31 09:21 .rnd
drwxr-xr-x 2 root root 1024 Jul 21 13:05 .ssh
root@gopigo3:~# cd /ros
bash: cd: /ros: No such file or directory
root@gopigo3:~#

and finally a screen shot:

Hi,
Before connecting to a device from the web terminal, you are presented with a dropdown to choose whether to connect to the host os or one of the containers of your application.
When connecting using balena ssh you also have the option to define the container that you want to SSH into, otherwise balena ssh will just connect to the host os.
As far as I can see from your above message you are not specifying a service/container name.
Please try running balena ssh dd641d8 main.
Let me also point you to our documentation pages about balena ssh:


Thanks. Now if I do a regular ssh from the command line (-p 22222) how do I indicate what service or container I want to be in?

Regular ssh will only log you into the hostOS. Once there, you can check with balena ps which containers are up and running, note down the container ID of the one you want to log into and then do a balena exec -ti <container id> /bin/shfor example.

Gotcha.

Does running in “development” mode make it more convenient?

What do you mean? Convenient in what way?

I just want to ssh into the application instead of the extra steps.

Development image won’t make it easier for that. So to ssh to your app you can use the balena cli ssh as my colleague explained, or do as I mentioned above or you can use the webterminal in case you are using balenaCloud.

1 Like

I use vscode to edit code. Normally I can open a file via an ssh (using a vscode plugin). Is that essentially impossible, because I have to ssh into the supervisor and then use balena exec to be able to get a shell in the app? Is there any other way to go or do I just have to use nano to edit?

I think there is no need to try to edit code in the container directly. You should take advantage of the tools we offer: https://www.balena.io/docs/learn/develop/local-mode/

I guess if I understood it.

But don’t you realize that the more new tools you ask me to use the less likely it is for me to succeed. First help me with the toolchain I know and then invent newer more clever things that will optimize my life.

Lets say that I still want to use vscode the way I explained, is it not possible then?

Pito Salas
Brandeis Computer Science
Volen 134

Hi Pito,
The problem with the approach you want to use is that, if you edit the code on the device, this change won’t get reflected in your application code on your host computer. That means any changes you do on the device will be lost if the container gets recreated, for example. The whole point of docker images/containers is for them to be portable, and the way you want to do things basically removes all benefits.

We do support the toolchain you know (which is VScode), it is just a different, simpler, mental model where you edit your application locally and that gets reflected on the device in near realtime, instead of needing to ssh into a device (directly or indirectly). It is literally just enabling local mode and running a single balena push command, so I don’t think it is something complex you need to learn. Let us know if you get stuck somewhere else, and we’d be happy to help you succeed :slight_smile: