Skip to content

SSH and Network Connections

Tony Zheng edited this page Jan 16, 2018 · 11 revisions

Introduction

SSH (Secure Shell) is a useful tool to remotely connect to another machine (e.g. your computer to the odroid on the barc). Once the connection is established you will have access to the filesystem and all command line tools on the odroid, including the launch of ROS nodes. There’s also a method to run a distributed ROS-system (more info below) where one roscore runs on one specified machine, while the nodes are running on different machines, while still communicating via topics and messages as if they were on the same machine.

Terminology

  • username - name of user. One machine many have many users. You can check it with the command $ whoami
  • hostname - name of system DNS (Domain name system). This information is important when a machine is connected to a network of other machines. You can check it with the command $ hostname

Typically, at the terminal command prompt, you'll see <username>@<hostname>.

Steps for remote connection to odroid via ssh

  1. First, connect to odroid's network. If the odroid has a Xilinx router connected to it, the network name and password are written on the router itself. If you’re using a wireless AP utility (instead of the router), the network credentials are in the file /etc/init/accesspoint.conf

  2. Open a terminal and enter $ ssh odroid@192.168.100.100 and enter the password when prompted (default pwd: odroid) Note that the IP address of the odroid might change, can check by running the command ifconfig -a on the odroid

Set up automatic ssh

You can automatically connect to the odroid using ssh-keys (as opposed to supply credentials every time you log in). Run the following commands on your machine

$ ssh-keygen                                                         # create key on your computer
$ ssh-copy-id odroid@192.168.100.100                                 # copy it to the odroid
$ ssh-keyscan -H odroid, 192.168.100.100 >> ~/.ssh/known_hosts       # add the odroid to your known_hosts file

More info: Follow the steps in this tutorial. Note, after following those steps, you'll need to also run ssh-add and ssh-keyscan -H odroid,192.168.100.100 >> ~/.ssh/known_hosts

IMPORTANT: For ROS communication across multiple machine, the ssh connection needs to use an RSA protocol for authentication. To ensure your using this authentication method, use the command ssh -o HostKeyAlgorithms=ssh-rsa odroid@192.168.100.100

Useful extra information SSH uses port number 22

Useful networking commands

$ ssh <username>@<remote-address>          # ssh connect to remote server
$ pinky                                    # lists current user
$ who                                      # lists current user information
$ whoami                                   # print current user ID (i.e. username)
$ ifconfig -a                              # show ip configuration
$ hostname                                 # print hostname

ROS on multiple machines

The command roscore runs on one machine, but many ROS nodes can run across several machines in a network. The following steps cover the process

  1. Select a master computer to run roscore
  2. Get the hostname of master computer using $ hostname
  3. Add the environment variable ROS_MASTER_URI with the command $ export ROS_MASTER_URI=http://<hostname>:11311 on all machines. Note, if does not work, use the respective IP-address instead.
  4. In your launch file, define "machine" and address tags and pass them to every node that is started. For more information, read here. A simple launch script would be
<launch>
  <machine name="foo" address="foo-address" env-loader="/opt/ros/fuerte/env.sh" user="someone"/>
  <node machine="foo" name="footalker" pkg="test_ros" type="talker.py" />
</launch>

For an example, refer to this example launch file

Remote Desktop

When you use SSH to connect to the odroid terminal, it may feel difficult to edit files and you also need to re-enter the SSH commands each time you open a new tab. Fortunately, you can use a remote desktop software such as VNC Viewer to interact with the odroid's desktop directly from your computer. Complete the following steps (odroid first) to use a virtual desktop software:

On odroid:

  1. Open a terminal and enter sudo bash ~/barc/scripts/fix_vino.sh. When prompted for the password, type odroid.
  2. Enter Y when asked to re-install vino.
  3. Wait for odroid to reboot.

On computer:

  1. Install VNC Viewer on your computer.
  2. Run VNC Viewer and click File>New Connection.
  3. In the VNC Server prompt, type your default odroid IP address e.g. 10.0.0.1.
  4. Enter a Name for this connection and click Ok.
  5. Connect to the odroid.

If an error occurs such as encryption or rgb pixel format, run the fix_vino.sh script on the odroid again.