Tuesday, November 04, 2014

Failed to ssh into Beaglebone Black

Yesterday when I was trying to update the OpenCV in my BBB, a strange thing happened. After downloading and unzipping OpenCV 2.4.9 in BBB [1], I couldn't log into my BBB via ssh (but using the webpage still worked). The terminal responded nothing, and it just hanged there without logging in.

The Cloud9 IDE helped in the test. It connect to your BBB and allow you to do something with JavaScript (I tested two of them which will be listed below).

I searched and tested, the first script given in the mail list [2] didn't work to me. It returned ``it seems that you have another problem, sorry.''

Then I tested the second script [3]. After running that script I logged in BBB via ssh again.

Actually I still have no idea what'd happened. Maybe the resource of BBB had been run out after the downloading of OpenCV? Maybe something else caused the problem.


I read the mail list again and found the post which listed the second script had said something may be useful. It talked about systemd-journal settings.

[1] I wouldn't do it again. At the beginning, I was planning to build OpenCV 2.4.9 in my BBB. Later, I read VAT's article and knew that I should use cross-compilation.

[2] The script:

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");

[3] The script worked for me:

var exec = require('child_process').exec;
function puts(error, stdout, stderr) { console.log(error); console.log(stdout); console.log(stderr); }

// 1 - Clear journal space
exec("df -h; rm -rf /var/log/journal/; df -h", puts);

// 2 - Remove Dropbear file
exec("rm /etc/dropbear/dropbear_rsa_host_key", puts);

// 3 - Stop Dropbear
exec("/etc/init.d/dropbear stop", puts);

// 4 - Start Dropbear
exec("/etc/init.d/dropbear start", puts);

No comments:

Post a Comment