Go to Top

SSH over USB to BeagleBone Black

I picked up a BeagleBone Black, and immediately I’m impressed. This thing seems ‘polished’ in comparison to other DIY hardware packages. The default Angstrom distribution, not my favorite by a long shot might I add, is configured very well. Plugging in the USb cable from my Fedora/Macbook hybrid, the blue LED’s immediately come to life, and I am directed to head over to http://192.168.7.2. This address, of course being the IP of the BBB, has a webserver up and running, and it is directly speaking to the hardware on board. There is even a link to run a local script, which keeps all the LEDs light for a short period of time. Slick.

Immediately, I know I’m going to enjoy this embeded Linux machine. Of coure, the next thing I attempt is to SSH over USB to my new toy:

ssh 192.168.7.2 -l root
ssh_exchange_identification: read: Connection reset by peer

Damn.

The .ssh/known_hosts file isn’t happy, on the BBB. Luckily, we have a way of getting there and cleaning things up. This is provided through the (SUPER SLICK) on board Cloud9 IDE. Access it here: http://192.168.7.2:3000/. By running the following script in the browser, we can clean up the known_hosts file, and give ourselves SSH access to the hardware.

var fs = require('fs');
var destroyed_key_file = '/etc/dropbear/dropbear_rsa_host_key';
fs.readFile(destroyed_key_file, function (err, data) {
if (err) throw err;

if( data===null || data.length===0 )
{
console.log("we have a corrupted host key file... try do delete it");
fs.unlink(destroyed_key_file, function (err) {
if (err) throw err;
console.log('successfully deleted ' + destroyed_key_file);
console.log('you should now reboot your beaglebone.');
console.log('the /etc/init.d/dropbear script will create a new rsa host key file for you.');
console.log('after the reboot you should be able to login over ssh');
});
} else {
console.log("it seems that you have another problem, sorry");
}
});

This code snippet came from a mailing list post, which can be found here.
Reboot, and you should be good to go:

[jayt@localhost ~]$ ssh 192.168.7.2 -l root
The authenticity of host '192.168.7.2 (192.168.7.2)' can't be established.
RSA key fingerprint is bd:e7:0d:68:58:0e:4a:ab:08:9a:54:c5:39:d5:51:a0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.7.2' (RSA) to the list of known hosts.
root@192.168.7.2's password:
root@beaglebone:~#

Comments (7)

  • Stephanie DiBianco February 23, 2014 - 9:03 pm Reply

    Nice work, very helpful.

  • Dimitri April 2, 2014 - 2:19 pm Reply

    It resolves my problem, thanks!

  • Soren April 17, 2014 - 4:46 pm Reply

    I am only getting “true” output in the console when I try to run the code.
    What am I doing wrong?

  • Soren April 17, 2014 - 4:47 pm Reply

    Op! Got it, I was using Safari, I switched to Chrome and it worked instantly. THANK YOU!

  • 101glover July 31, 2014 - 6:07 pm Reply

    This worked for me and I appreciate you posting it but what is the ” -l ” option? I don’t understand why it is included.

  • 101glover July 31, 2014 - 6:09 pm Reply

    to clarify ssh 192.168.7.2 -l root worked for me and I am inquiring about the -l option in this command.

    • jay August 2, 2014 - 7:24 pm Reply

      The -l option lets you specify a user account in the destination host you want to login into. In this case, we wanted to login as the root account. Alternatively, you could have used: root@192.168.7.2

Leave a Reply