Skip to content

Commit 5531f8d

Browse files
authored
Merge pull request #2685 from arduino/karlsoderby/ssh-tutorial
[PXCT-1522] SSH tutorial for UNO Q
2 parents 446f78e + 3a1761c commit 5531f8d

File tree

6 files changed

+204
-0
lines changed

6 files changed

+204
-0
lines changed
315 KB
Loading
348 KB
Loading
236 KB
Loading
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
title: Connect to UNO Q via Secure Shell (SSH)
3+
description: Learn how to access an UNO Q's shell via SSH.
4+
tags: [UNO Q, SSH, Terminal]
5+
author: Karl Söderby
6+
---
7+
8+
The [Arduino® UNO Q](https://store.arduino.cc/products/uno-q) can be programmed via the [Arduino App Lab](/software/app-lab/), a desktop application supporting code editing and running [Apps](/software/app-lab/tutorials/getting-started/#create--run-apps) on the board without any external tools.
9+
10+
The board's microprocessor (running Debian OS) can also be accessed using Secure Shell (SSH), a method that allows remote connection to your board over a local network. This allows you to, among other things:
11+
- Access the board's shell and perform operations on the board remotely.
12+
- Transfer files from your local computer to the board remotely (using SCP).
13+
14+
The UNO Q board comes pre-packaged with the Arduino App Lab, which is based on the `arduino-app-cli` tool<sup>1</sup>. This allows you, among other things, to **launch Apps through the command line**, instead of using the desktop App.
15+
16+
<sup>1</sup> Read more about the `arduino-app-cli` in the [Arduino App CLI guide](/software/app-lab/tutorials/cli/).
17+
18+
## Requirements
19+
20+
### Hardware Requirements
21+
22+
- [Arduino® UNO Q](https://store.arduino.cc/products/uno-q)
23+
- 5 VDC 3 A power supply (e.g., a phone charger or USB port from a computer)
24+
25+
### Software Requirements
26+
27+
- [First setup](/software/app-lab/tutorials/getting-started/#install--set-up-arduino-app-lab) of board completed\*
28+
- An SSH client tool installed on the computer (macOS, Windows 10+, Ubuntu has built-in SSH client tools)
29+
- Access to a local Wi-Fi® network (both computer & board need to be on the same network)
30+
31+
***During the first setup, Wi-Fi® credentials are entered, and the board will automatically enable SSH. Without completing it, it is not possible to access the board via SSH unless activated manually. This can also be activated by accessing the board using `adb`, and running `arduino-app-cli system network-mode enable` in the board's shell. See more in the [Arduino App CLI documentation](/software/app-lab/tutorials/cli/)***
32+
33+
## Installing SSH (Local Computer)
34+
35+
SSH is a network protocol, not a tool itself. There are many different SSH tools to choose from, and most operating systems have a built-in tool. In this section, we will cover how to set it up on some common operating systems (macOS, Windows, Ubuntu).
36+
37+
### macOS
38+
39+
macOS features a built-in `ssh` tool based on [OpenSSH](https://www.openssh.com/), and **should work out of the box**. Check if the tool is present on your machine by running the following in a terminal:
40+
41+
```
42+
ssh -V
43+
```
44+
45+
You should see something like:
46+
47+
```
48+
OpenSSH_9.9p2, LibreSSL 3.3.6
49+
```
50+
51+
Which means it is working properly. ✅
52+
53+
***If you are running an outdated/custom system that for some reason does not feature SSH, you can look into installing [OpenSSH](https://formulae.brew.sh/formula/openssh) and [LibreSSL](https://formulae.brew.sh/formula/libressl) manually via, e.g., Brew.***
54+
55+
56+
### Windows
57+
58+
Later versions of Windows (10+) include SSH clients as well, with no requirement to install additional tools. To verify tools are installed, open a terminal on your Windows machine, and type:
59+
60+
```
61+
ssh -V
62+
```
63+
64+
Which should return something like:
65+
66+
```
67+
OpenSSH_for_Windows_x.x, LibreSSL 3.x.x
68+
```
69+
70+
This means it is working properly. ✅
71+
72+
***For older Windows machines, use a package manager such as [Chocolatey](https://chocolatey.org/) to install OpenSSH / LibreSSL.***
73+
74+
### Linux (Ubuntu)
75+
76+
Many Linux OS include SSH clients, with no requirement to install additional tools. To verify tools are installed, open a terminal on your Ubuntu machine, and type:
77+
78+
```
79+
ssh -V
80+
```
81+
82+
Which should return something like:
83+
84+
```
85+
OpenSSH_x.x Ubuntu-3ubuntu.x, OpenSSL x.x.x
86+
```
87+
88+
This means it is working properly. ✅
89+
90+
***If you are running an outdated/custom system that for some reason does not feature SSH, you can look into installing [OpenSSH](https://formulae.brew.sh/formula/openssh) and [LibreSSL](https://formulae.brew.sh/formula/libressl) manually, by running `sudo apt install openssh-client openssh-server libressl-dev`.***
91+
92+
## Connecting via SSH
93+
94+
To connect to an UNO Q board via SSH, we only need to know the **board name and password**. This is set up during the first setup.
95+
96+
1. Open a terminal.
97+
2. Run the following command:
98+
99+
```
100+
ssh arduino@<boardname>.local #replace <boardname> with your board name
101+
```
102+
103+
3. Type `yes` when asked to connect.
104+
4. Enter the password for the board.
105+
106+
After entering the password, you should enter the board's shell, and you can now perform operations!
107+
108+
See below how it should look when you have successfully accessed the board's shell.
109+
110+
### macOS Confirmation
111+
112+
![macOS SSH access](assets/ssh-macos.png)
113+
114+
#### MacOS MDNS Issues
115+
116+
If the connection fails with the following error:
117+
- `ssh: connect to host <boardname>.local port 22: Connection refused`
118+
119+
It might be a mDNS issue with your local network. To work around this, there are some alternatives to try:
120+
121+
**Connect directly via the IP address:** The board's IP address can be found through:
122+
- Arduino IDE 2 (needs the Zephyr core installed)
123+
- Arduino CLI, by running `arduino-cli board list`
124+
- Running `hostname -I` while in the board's shell. You can access the board via `adb shell` ([instructions](/software/app-lab/tutorials/cli/#connect-via-adb)), or [using the board in SBC mode](/tutorials/uno-q/single-board-computer/).
125+
126+
After obtaining the IP address, you should be able to connect via SSH using `ssh arduino@10.0.20.138`.
127+
128+
***If you have previously connected to a board with the same IP address, but have re-flashed the board, you may need to remove the old key from `~/.ssh/known_hosts`. This can be done by editing the `known_hosts` file or by running `ssh-keygen -R <board ip address>`.***
129+
130+
### Windows Confirmation
131+
132+
![Windows SSH access](assets/ssh-windows.png)
133+
134+
### Linux (Ubuntu) Confirmation
135+
136+
![Linux (Ubuntu) SSH access](assets/ssh-linux.png)
137+
138+
## Arduino App CLI
139+
140+
The `arduino-app-cli` can be used to start & stop Apps on the board from the terminal. When accessing the board via SSH, you can run commands such as `arduino-app-cli app start <app>`.
141+
142+
More details on the `arduino-app-cli` tool can be found in the [Arduino App CLI guide](/software/app-lab/tutorials/cli/).
143+
144+
## File Transfer
145+
146+
To transfer files from your computer to the board, use the `scp` tool **from your computer's terminal** (not inside an SSH session on the board). The tool can be used to either **push** or **pull** files and folders to and from the board.
147+
148+
This is done by specifying a local path on your computer (e.g., `/User/documents/file.xx`), and a path on the board (e.g., `/home/arduino/`).
149+
150+
### Push Files
151+
152+
To **push** a file, use the command below:
153+
154+
```
155+
scp test-transfer.txt arduino@<boardname>.local:/home/arduino/
156+
```
157+
158+
This will transfer the `test-transfer.txt` file in the same directory you are running the command, to the board.
159+
160+
### Pull Files
161+
162+
To **pull** a file, use the command below:
163+
164+
```
165+
scp arduino@<boardname>.local:/home/arduino/test-transfer.txt ./
166+
```
167+
168+
This will pull the file to the directory where you run the command. `./` can be replaced by specifying a path (e.g., `/User/documents/`).
169+
170+
### Push/Pull Folders
171+
172+
To **push** a folder, use `-rp` to copy directories **r**ecursively, and **p**reserve times/permissions:
173+
174+
`scp -rp "my-folder" arduino@<board-name>.local:/home/arduino/ArduinoApps/`
175+
176+
To **pull** a folder from the board to your current directory:
177+
178+
`scp -rp arduino@<board-name>.local:/home/arduino/ArduinoApps/my-folder ./`
179+
180+
181+
## Troubleshooting
182+
183+
If the SSH connection fails, there are some common things to check:
184+
- Has the first setup been completed? If not, follow the instructions [here](/software/app-lab/tutorials/getting-started/#install--set-up-arduino-app-lab) and see the instructions. The first setup will enable SSH on the board, which is required to connect.
185+
- If the SSH connection gets stuck even though the first setup has been completed, it may be a local network issue. Check that the board is connected to the same network as your computer.
186+
187+
### Issues with MDNS
188+
189+
Some networks may block using mDNS, which allows us to use a "friendly" name (`arduino@<boardname>.local`), instead of using the actual IP address of the board. There are two ways to work around this:
190+
1. Instead of using `arduino@<boardname>.local`, use the board's IP address directly. The IP address can be accessed by either launching the board in SBC mode and typing `hostname -I` in a terminal. This will reveal the IP address of your board.
191+
2. (advanced) Edit the `/etc/hosts` on your local computer by running `sudo nano /etc/hosts`. At the bottom of the file, add `<boardipaddress> <boardname>.local`. This will allow you to connect using `ssh arduino@<boardname>.local`.

content/software/app-lab/tutorials/03.cli/apps-lab-cli.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,19 @@ To verify the tool is installed, run `adb version`.
7474

7575
5. You are now able to run commands via the terminal on your board! To exit from the terminal, simply type `exit`.
7676

77+
## Connect via SSH
78+
79+
***Note: to use SSH, the [first setup]() needs to be completed. This is done by connecting your board via USB, open the Arduino App Lab, and select the USB option. Here you will need to give your board a name, a new password as well as providing Wi-Fi® credentials. SSH will be automatically configured during this setup.***
80+
81+
1. Open a terminal on your machine.
82+
2. Run `ssh arduino@<boardname>.local`
83+
3. Provide the password for the board.
84+
4. We can now interact with the board's shell remotely! ✅
85+
86+
![Connect via SSH](assets/ssh-macos.png)
87+
88+
- A more detailed tutorial on connecting to the UNO Q via SSH is available [here](/tutorials/uno-q/ssh).
89+
7790
## Using Arduino App CLI
7891

7992
With the `arduino-app-cli` tool, you can for example:
348 KB
Loading

0 commit comments

Comments
 (0)