|
| 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 | + |
| 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 | + |
| 133 | + |
| 134 | +### Linux (Ubuntu) Confirmation |
| 135 | + |
| 136 | + |
| 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`. |
0 commit comments