Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
BeagleBone Black Cookbook

You're reading from   BeagleBone Black Cookbook Over 60 recipes and solutions for inventors, makers, and budding engineers to create projects using the BeagleBone Black

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher Packt
ISBN-13 9781783982929
Length 346 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Toc

Table of Contents (11) Chapters Close

Preface 1. Setting Up for the First Time FREE CHAPTER 2. Basic Programming Recipes 3. Physical Computing Recipes Using JavaScript, the BoneScript Library, and Python 4. Exploring GNU/Linux Recipes Using Bash, Autotools, Debugger, and systemd 5. Basic Programming Recipes with the Linux Kernel 6. Run Faster, Run Real Time 7. Applied Recipes – Sound, Picture, and Video 8. The Internet of Things 9. The Black in Outer Space Index

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:

  1. Command line via SSH
  2. 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:

  1. Open LXTerminal.
  2. Now, enter the following command:
    ~$ sudo ifconfig
    
  3. In the onscreen text, get the IP address of your BBB. Under etho0, look for inet addr: xxx.xxx.xxx.xxx.

On your PC/Mac/Linux box:

  1. Open your preferred terminal app. On the Mac, it's just called Terminal.
  2. At the command prompt, type the following:
    ~$ ssh-keygen -R <your_ip_address>
    
  3. You should then get the following:
    /Users/username/.ssh/known_hosts updated.
    Original contents retained as /Users/ username/.ssh/known_hosts.old
    username@hrh:~$
    
  4. Next, type the following:
    username@devicename:~$ ssh debian@<your_ip_address>
    
  5. 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)?
    
  6. Type yes (no quotes, all lowercase).
  7. 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:
    
  8. Type the password of your BBB login (the default is temppwd).
  9. 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:

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:

  1. Install the client app on your desktop box.
  2. From the terminal window, run the VNC server on the BBB through the following command:
    $ vncserver
    
  3. 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.

  4. 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.
    How to do it...
  5. You will then have a window pop up Unencrypted Connection.
  6. Click Continue.
  7. 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/.
You have been reading a chapter from
BeagleBone Black Cookbook
Published in: Nov 2015
Publisher: Packt
ISBN-13: 9781783982929
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image