SSH CLI Client
Level: Medium
Duration: 45 minutes
Prerequisites: Configure SSH Access / Submit an Experiment with A8 nodes / Experiment CLI client
Description: The goal of this tutorial is to show how to use the SSH CLI Client on the frontend SSH. This client provides a set of commands for interacting remotely and easily with IoT-Lab Open A8 nodes. You will learn how to submit an experiment with A8 nodes on the Saclay site, wait for the Linux kernel boot. After you will see how to flash a tutorial firmware on the A8-M3 nodes, run commands and execute a script in background mode.
ssh-cli-tools
is a python SSH client for IoT-LAB A8 nodes. Of course you can install it directly on your computer and follow the tutorial in the same way. You can find information about it on the corresponding IoT-LAB GitHub repository- Connect to Saclay site SSH frontend
my_computer$ ssh <login>@saclay.iot-lab.info
Note: if you did not already authenticate using iotlab-auth, do it now:
<login>@saclay:~$ iotlab-auth -u <login>
- BEFORE any experiment submission, add the ssh public key of your local user on the ssh frontend to your global User profile. You can get this key as below and follow this tutorial.
<login>@saclay:~$ cat ~/.ssh/id_rsa.pub
- Start an experiment with 2 A8 nodes (eg. dynamical nodes allocation by the scheduler)
<login>@saclay:~$ iotlab-experiment submit -d 60 -l 2,archi=a8:at86rf231+site=saclay
Note: Remember the experiment identifier returned by the last command. It’ll be used in the commands shown below,
<exp_id>
. The requested experiment duration is 60 minutes. - Wait a moment until the experiment is launched and get the A8 nodes list. For the next of this tutorial we suppose that we obtain a8-1.saclay.iot-lab.info and a8-2.saclay.iot-lab.info nodes.
<login>@saclay:~$ iotlab-experiment wait Waiting that experiment <exp_id> gets in state Running "Running" <login>@saclay:~$ iotlab-experiment get -p { "deploymentresults": { "0": [ "a8-1.saclay.iot-lab.info", "a8-2.saclay.iot-lab.info" ] }, "duration": 60, "nodes": [ "a8-1.saclay.iot-lab.info", "a8-2.saclay.iot-lab.info" ], "state": "Running", "type": "physical" }
Note: deploymentresults attribute in the JSON is the result of the submit experiment request on the IoT-LAB A8 nodes. It informs you that the A8 node has well-received the start Linux booting operation. After you must verify that the A8 node has booted correctly and was reachable with the next step 5 and SSH CLI client wait-for-boot command.
- Verify that the Linux system is booting on A8 nodes and if they are reachable by SSH. By default this command is waiting with a default timeout of 120 seconds and you can modify this value with the command-line option –max-wait.
<login>@saclay:~$ iotlab-ssh wait-for-boot { "wait-for-boot": { "0": [ "node-a8-1.saclay.iot-lab.info", "node-a8-2.saclay.iot-lab.info" ] } }
Note: you can test manually that the A8 node is reachable with this command
<login>@saclay:~$ ssh root@node-a8-1 root@node-a8-1:~# uname -a Linux node-a8-1 3.18.5-iotlab+ #2 Tue Feb 3 15:01:11 CET 2015 armv7l GNU/Linux
- Flash the tutorial firmware on the A8-M3 nodes.
<login>@saclay:~$ wget https://raw.githubusercontent.com/wiki/iot-lab/iot-lab/firmwares/tutorial_a8_m3.elf -O tutorial_a8_m3.elf <login>@saclay:~$ iotlab-ssh flash-m3 tutorial_a8_m3.elf { "flash-m3": { "0": [ "node-a8-1.saclay.iot-lab.info", "node-a8-2.saclay.iot-lab.info" ] } }
If you want to visualize the standard output (eg. stdout) of the command on the A8 nodes you can use the command-line option –verbose
<login>@saclay:~$ iotlab-ssh --verbose flash-m3 tutorial_a8_m3.elf
You can also specify a list of nodes as below where you want to run the command. By default we execute the command on all A8 experiment nodes.
<login>@saclay:~$ iotlab-ssh flash-m3 tutorial_a8_m3.elf -l saclay,a8,1 <login>@saclay:~$ iotlab-ssh flash-m3 tutorial_a8_m3.elf -e saclay,a8,2
Verify on A8 node that you can read the A8_M3 node serial link and view tutorial firmware prompt
<login>@saclay:~$ ssh root@node-a8-1 root@node-a8-1:~# miniterm.py --echo /dev/ttyA8_M3 500000 --- Miniterm on /dev/ttyA8_M3: 500000,8,N,1 --- --- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- IoT-LAB Simple Demo program Type command h: print this help u: print node uid d: read current date using control_node s: send a radio packet b: send a big radio packet e: toggle leds blinking Type Enter to stop printing this help cmd >
Note: the command-line flash-m3 option takes place in two stages. Firstly we copy the firmware binary file in the A8 directory of your home directory on the frontend SSH. This directory is mounting (eg. NFS) by all A8 experiment nodes. After we launch flash_a8_m3 command with the corresponding firmware on the A8 nodes.
<login>@saclay:~$ ls A8/.iotlabsshcli/tutorial_a8_m3.elf
- Reset the A8-M3 nodes
<login>@saclay:~$ iotlab-ssh reset-m3 { "reset-m3": { "0": [ "node-a8-1.saclay.iot-lab.info", "node-a8-2.saclay.iot-lab.info" ] } }
- You can also run a command (eg. Linux uptime command ) on A8 nodes.
<login>@saclay:~$ iotlab-ssh --verbose run-cmd uptime Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-1.saclay.iot-lab.info:22 Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22 [node-a8-1.saclay.iot-lab.info] 11:14am up 0:00, 1 user, load average: 0.16, 0.06, 0.02 [node-a8-2.saclay.iot-lab.info] 11:14am up 0:00, 1 user, load average: 0.51, 0.16, 0.06 { "run-cmd": { "0": [ "node-a8-1.saclay.iot-lab.info", "node-a8-2.saclay.iot-lab.info" ] } }
- Launch the A8-M3 nodes serial link redirection. After you can access directly (eg. netcat command) from the frontend SSH the serial link without A8 nodes SSH access.
<login>@saclay:~$ iotlab-ssh --verbose run-cmd "nohup /etc/init.d/serial_redirection start >/dev/null 2>&1" Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-1.saclay.iot-lab.info:22 Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22 [node-a8-1.saclay.iot-lab.info] Starting serial_redirection /dev/ttyA8_M3:20000 0 [node-a8-2.saclay.iot-lab.info] Starting serial_redirection /dev/ttyA8_M3:20000 0 { "run-cmd": { "0": [ "node-a8-2.saclay.iot-lab.info", "node-a8-3.saclay.iot-lab.info" ] } } <login>@saclay:~$ nc node-a8-2 20000
- Print the A8 nodes IPv6 configuration
<login>@saclay:~$ iotlab-ssh --verbose run-cmd "source /var/local/config/ipv6; printenv" Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22 Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-1.saclay.iot-lab.info:22 [node-a8-1.saclay.iot-lab.info] INET6_PREFIX_LEN=64 [node-a8-1.saclay.iot-lab.info] INET6_PREFIX=2001:0660:3207:403 [node-a8-1.saclay.iot-lab.info] GATEWAY6_ADDR=2001:0660:3207:0400:ff:: [node-a8-1.saclay.iot-lab.info] INET6_ADDR=2001:0660:3207:0400::3/64 ... [node-a8-2.saclay.iot-lab.info] INET6_PREFIX_LEN=64 [node-a8-2.saclay.iot-lab.info] INET6_PREFIX=2001:0660:3207:402 [node-a8-2.saclay.iot-lab.info] GATEWAY6_ADDR=2001:0660:3207:0400:ff:: [node-a8-2.saclay.iot-lab.info] INET6_ADDR=2001:0660:3207:0400::2/64 { "run-cmd": { "0": [ "node-a8-2.saclay.iot-lab.info", "node-a8-1.saclay.iot-lab.info" ] } }
- Install an ipk package on A8 nodes. Firstly you copy the package on the frontend SSH (eg. A8 directory) and after launch the package installation command on only one node. Indeed all A8 experiment nodes shared filesystem parts (eg. NFS filesystem) and it’s the case of opkg package manager. So when you install a package on one A8 node you can use it on all experiment nodes.
<login>@saclay:~$ wget https://raw.githubusercontent.com/wiki/iot-lab/iot-lab/packages/iperf_2.0.5-r0_cortexa8hf-neon.ipk -O iperf_2.0.5-r0_cortexa8hf-neon.ipk <login>@saclay:~$ iotlab-ssh --verbose copy-file iperf_2.0.5-r0_cortexa8hf-neon.ipk { "copy-file": { "0": [ "saclay.iot-lab.info" ] } } <login>@saclay:~$ iotlab-ssh --verbose run-cmd "opkg install ~/A8/.iotlabsshcli/iperf_2.0.5-r0_cortexa8hf-neon.ipk" -l saclay,a8,2 Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22 [node-a8-2.saclay.iot-lab.info] Installing iperf (2.0.5-r0) to root... [node-a8-2.saclay.iot-lab.info] Configuring iperf. { "run-cmd": { "0": [ "node-a8-2.saclay.iot-lab.info" ] } } <login>@saclay:~$ ssh root@node-a8-1 root@node-a8-1:~# iperf --help
Note1: We have deployed a Beta Yocto Linux distribution on Saclay site. If you use another IoT-LAB site and play this tutorial you must replace iperf_2.0.5-r0_cortexa8hf-neon.ipk with the old corresponding name iperf_2.0.5-r0_armv7a-vfp-neon.ipk.
Note2: Be careful if you want to manage a daemon with init scripts you must install your script on all experiment nodes.
- Run a script in background (eg. screen session) on A8 nodes. Edit a python script file test_run_script.py as follows
<login>@saclay:~$ cat test_run_script.py #!/usr/bin/env python import time def main(): while True: print("Test iotlab-ssh run-script") time.sleep(2) if __name__ == '__main__': main()
<login>@saclay:~$ iotlab-ssh --verbose run-script test_run_script.py Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22 Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-1.saclay.iot-lab.info:22 [node-a8-2.saclay.iot-lab.info] No screen session found. [node-a8-1.saclay.iot-lab.info] No screen session found. Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-2.saclay.iot-lab.info:22 Connecting via SSH proxy saclay.iot-lab.info:22 -> node-a8-1.saclay.iot-lab.info:22 { "run-script": { "0": [ "node-a8-1.saclay.iot-lab.info", "node-a8-2.saclay.iot-lab.info" ] } } <login>@saclay:~$ ssh root@node-a8-1 root@node-a8-1:~# screen -ls There is a screen on: 2026.<exp_id>-<login> (Detached) 1 Socket in /tmp/screens/S-root. root@node-a8-1:~# screen -r Test iotlab-ssh run-script Test iotlab-ssh run-script ...
Note: Use “Ctrl+a d” shortcut to detach screen session after “screen -r” command