SSH / Remote access
Local control of your BBB should always be supplemented with the ability to control it remotely. There are a variety of reasons you may want to do this. For example, you may want to operate the device from one location while you are in another location.
The primary and most typical reason for remote access, however, is to run the board headlessly. This means running it without a display, keyboard, or mouse. Headless control is, in fact, the way I operate the board about 99 percent of the time. I rarely even use an external monitor with the BBB since it requires fewer pieces of hardware and reduces headache.
There are two basic recipe types for remote usage:
- Command line via SSH
- GUI-centric via VNC
Using SSH to control your BBB
Using SSH (secure shell) on a desktop PC or other client will give you control over your BBB across a network. Here is the recipe.
How to do it…
On your BBB:
- Open LXTerminal.
- Now, enter the following command:
~$ sudo ifconfig
- In the onscreen text, get the IP address of your BBB. Under
etho0
, look forinet addr: xxx.xxx.xxx.xxx
.
On your PC/Mac/Linux box:
- Open your preferred terminal app. On the Mac, it's just called Terminal.
- At the command prompt, type the following:
~$ ssh-keygen -R <your_ip_address>
- You should then get the following:
/Users/username/.ssh/known_hosts updated. Original contents retained as /Users/ username/.ssh/known_hosts.old username@hrh:~$
- Next, type the following:
username@devicename:~$ ssh debian@<your_ip_address>
- Now, you will see the following on screen:
The authenticity of host '<your_ip_address> (<your_ip_address>)' can't be established. RSA key fingerprint is 97:b4:04:f5:24:f3:75:f9:90:3c:cc:ff:78:36:f3:d9. Are you sure you want to continue connecting (yes/no)?
- Type
yes
(no quotes, all lowercase). - You will then see the following with a new prompt:
Warning: Permanently added '<your_ip_address>' (RSA) to the list of known hosts. debian@<your_ip_address>'s password:
- Type the password of your BBB login (the default is
temppwd
). - If you typed in your password correctly, you will end up back here:
debian@beaglebone:~$
Congratulations! You've now gained control over your BBB using the command line from another box.
Using VNC to control your BBB
So, are you still not entirely comfortable with the command line and want access to some of the GUI-based tools? Or, do you need to test and control using an actual GUI? Or, perhaps, is your app not running properly from only the command line? Then, it's time for VNC.
Virtual Network Computing (VNC) allows remote access to a device that's running an X session or windows/GUI-based system from a remote device or client machine. With the current Debian distribution, running VNC is easier than ever as the BBB arrives preloaded with the relevant package, the TightVNC server. On your client box, you need to install a remote viewer.
Getting ready…
For your client box, download and install one of the following remote viewer applications:
- The Windows, Mac, and Linux boxes: http://www.tightvnc.com/
- VNC Viewer: http://www.realvnc.com/download/viewer/
Once again, we're cooking up a recipe from a Mac perspective, so VNC Viewer it will be.
How to do it...
As noted, the BBB now comes with the remote server installed, so the only new installation required is the one for your client box. For this, perform the following steps:
- Install the client app on your desktop box.
- From the terminal window, run the VNC server on the BBB through the following command:
$ vncserver
- Next, you will need your BBB's port address. You will find it in the status message now running in the CLI window:
New 'X' desktop is beaglebone:1
Note
Your port number may differ.
- On your desktop box:
- Open up VNC viewer (or whichever client app you're using)
- Type in the IP address of your BBB and the port number at the end of the VNC server field: 123.456.78.9:1. The default my be "beaglebone:1.
- You will then have a window pop up Unencrypted Connection.
- Click Continue.
- Select Connect.
You will now be logged in to your BBB, be able to see the desktop, and have full control over the device using the mouse on your client box.
There's more...
- Security: Using the default or basic settings in VNC is not secure. Unless you're familiar with doing so, the sessions are not encrypted. One quick, though imperfect, measure is to change from the default server port 5900 to a spare, randomly chosen port.
- Getting the IP address on a headless BBB: From another computer on the network, use the following steps to list a network's basket of IP addresses:
ifconfig | grep inet
- Note that this will show the IP address range and only name specific host devices but not other addresses.
- This method may only be feasible in a smaller network, where the number of addresses is more limited and you do not have to look for a needle in a haystack.
- You will likely need to install the NMap security scanner (http://nmap.org/). Check whether it's installed first.
- Then, type in
sudo nmap -sn -PE 192.168.1.0/24
(with the IP address of the host machine and then/xxx
from the end range shown in Step 1).
- Browse to the local router admin address: Find the configuration options that show all computers/devices on the network with their IP addresses.
- Set a static IP address: This takes several steps, but one of the best tutorials is Derek Molloy's at http://derekmolloy.ie/set-ip-address-to-be-static-on-the-beaglebone-black/.