Friday, December 22, 2017

Random pins

I keep forgetting this when setting up a new yubikey,

mgmt=`dd if=/dev/random bs=1 count=24 2>/dev/null | hexdump -v -e '/1 "%02X"'`
puk="$(< /dev/random tr -dc 0-9 | head -c8)"
pin="$(< /dev/random tr -dc 0-9 | head -c6)"

Saturday, April 30, 2016

Making a liveusb from an iso

Notes to self mainly. I'll forget this by the time I need it again.

I kept getting errors creating a liveusb for Ubuntu 16.04. Something about casper/filesystem.squashfs was broken. What worked when making the stick:

umount /dev/sdb1
sudo dd if=ubuntu-16.04-desktop-amd64.iso of=/dev/sdb bs=2048
sudo dd if=/dev/sdb bs=2048 count=725528 | sha256sum

Verify that the shasum on the stick matches what is in the shasums file, or do 2 & 3 over again. I tried a bs=1M a few times. That didn't work. I tried without specifying block size, that locked up centos (three for three) and I had to force a reboot. The count comes from doing a ls -l on the directory where the ISO is found, taking the number of bytes listed and dividing by the block size. In this case, 1485881344 was the file size of the ISO. For ubuntu, it should be divisible by 2048, so says the internet.

Sunday, February 15, 2015

XKCD password generator

My old password was one of those that is hard to remember, but easy for computers to guess.
I decided to take that comic's advice and use randomly selected common words. To do that, I needed a list of common words and a way to randomly select them. I'm using Ubuntu these days, and fortunately, everything I need is a one liner in the terminal:

sort -R /usr/share/dict/american-english | head -n 4

In this case, 4 is the number of words. To gauge the strength of this password, I looked at the number of words in the file, about 100000 or 10^5. Four words as the comic suggests then would be about 10^20 or 67 bits in base 2 according to wolframalpha. Eight words from this file, it seems, would give more bits of entropy than a 128bit encryption key

Edit: I noticed the random function here isn't very random. To fix that,

sort -R --random-source=/dev/random /usr/share/dict/american-english | head -n 4

Sunday, July 20, 2014

Installing Virtualbox on Acer C720 chromebook under crouton

So there's this great new thing called Vagrant. Basically, it's a system designed to solve all your problems when it comes to putting together a development environment for a team of people. Sounds great, so how do you install it?

Well, you need to download and install vagrant and virtualbox. Seems simple enough. sudo apt-get install virtualbox, right? Nope. You see, I'm using Ubuntu 14.04 on a Acer C720 chromebook. I'm running it chrooted using the crouton script.

In order to install virtualbox, you need to build the chromebook linux kernel because it doesn't have the 3.4 headers. I found a great step by step guide to do that here:

https://github.com/dnschneid/crouton/wiki/Build-kernel-headers-and-install-Virtualbox-%28x86%29

Nice. Follow the guide, and we're done? Not so fast... In order to build the chrome kernel, you need GCC 4.9. If you try to apt-get it on ubuntu 14.04, you might even think you've installed it, but the package is empty. You have to build this from source as well.

Okay, so to install Vagrant, I need virtualbox, which requires kernel headers, which requires me to build gcc 4.9. How do?

https://github.com/dnschneid/crouton/issues/939

To keep this brief, I'll just link to the issue I created on crouton. It details the steps I took to make virtualbox work on crouton. Posting this so my future self can find it if I ever need to reinstall my chromebook.


Saturday, February 1, 2014

Building RStudio on ARM

I finished building RStudio on my Nexus 5. I'm making these notes for anyone who might find them helpful, including my future self if I need to do it again for any reason. I assume you've already installed R with

sudo apt-get install r-base

First of all, you need to download the source for RStudio to your device. Just go to the github page and download the zip

https://github.com/rstudio/rstudio

Once you do that, you basically just need to follow the instructions in the INSTALL document

https://github.com/rstudio/rstudio/blob/master/INSTALL

There are some gotchas though. For starters, it says you need to install the dependencies, but it doesn't spell it out. I overlooked that section and started installing dependencies as I ran into the need for them one at a time with apt-get. So to spare yourself the trouble, cd into the dependencies/linux directory and

./install-dependencies-debian

(I assume you're running ubuntu on your phone. You may need one of the other scripts if not)

That took quite a while. Like hours it seemed. But it will finally finish building as long as you don't let you phone screen sleep.

That's another gotcha. I didn't have the problem installing dependencies by dumb luck. I decided to read some news on the web while it installed dependencies. That kept the phone awake and building. Later, when I built RStudio, I let it sleep and went to bed, only to wake to no progress in the build. I only figured it out because I forgot it was building, and left with the phone in my pocket.

I remembered a few hours later, but noticed the battery had not drained significantly. That told me the phone was idle and explained why there was no progress in the build. So I set screen sleep to 30 minutes and kept it awake and build progress began. It finished the build after 13 hours. It will probably only take a couple of hours if you keep the screen awake the whole time.

Finally, there's one last problem I encountered. I had to replace the compiler.jar in the source with a newer version. Specifically, this version

https://code.google.com/p/closure-compiler/downloads/detail?name=compiler-20130823.zip&amp;can=2&amp;q=

The version located in

src/gwt/tools/compiler

appears to hang forever when compiling gwt. I tried the latest version of the jar with no luck too. It required that specific version of compiler.jar to work, for whatever reason.

Also, there's a bonus possible gotcha. It's that you may need to build with the older JDK6 downloaded by the dependencies script. I read somewhere that it would not compile with the openjdk 7 which I had installed before installing RStudio. I didn't try building with JDK 7 because I just wanted it working at that point. If you have both installed, you can switch between them with

sudo update-alternatives --config java

Hopefully that helps save someone a lot of time. It ended up taking me more than a week to find all this.