Using the Chroot SSH trick


Recently I created a LabVIEW graphical interface for my LIRC Raspberry PI Universal remote. The first step in this process was getting LIRC to work in the chroot that runs on the Raspberry Pi. You can think of the chroot as a super lightweight virtual machine that LabVIEW runs in. Many folders have been mapped so they are shared between the host OS and the chroot, but LV cannot run a command (i.e. invoke an executable) that is outside the chroot. There is, however, one cheat though that would allow me to interact with LIRC when it is outside the chroot. This cheat involves downloading an ssh client to your chroot and then using a System Exec VI to run commands outside of the chroot. This is potentially very powerful because it allows LINX users to run programs that aren’t compatible with the chroot.

First, let’s talk about what a chroot is exactly. A chroot is a Linux construct that allows a process (like the LabVIEW run-time engine) set to run as if an arbitrary directory is the root directory. The way that we use a chroot with the LabVIEW run-time engine is to act as if LV was running within a very lightweight virtual machine. There are 2 reasons that LabVIEW runs within a chroot on the BeagleBone Black or Raspberry Pi 2:

  1. Using a chroot we can make one installer which will run on several different Linux distributions and devices since the chroot contains its own set of system libraries and other operating system files.
  2. The LabVIEW run-time engine is compiled with options that make it incompatible with the system libraries that are included in the default operating system images used with the BBB and RPi2/3, so the chroot allows us to include a set of system libraries for LabVIEW to use that are compiled with options that are compatible.

Since the LIRC wasn’t compatible with the chroot yet I spent some time on LabVIEW MakerHub, and I found a technique referred to as the “Chroot SSH Trick” This technique allows LabVIEW to run commands outside of its chroot on a LINX 3.0 (BBB or RPi2) target. This can be useful for interacting with commands that are unavailable inside the chroot, I have detailed the steps below.

  1. Install an SSH client to your chroot:
    • sudo schroot -r -c lv
    • opkg update
    • opkg install openssh-ssh
    • exit
  2. Configure pub key authentication so you don’t have to type in a password interactively (Hint: This let’s you use the SSH client from LabVIEW System Exec VI).
    • ssh-keygen -t rsa
    • stick with the defaults when it prompts you, especially when it asks for the passphrase; we want an empty passphrase
    • cat ~/.ssh/ >> ~/.ssh/authorized_keys
    • sudo mkdir /srv/chroot/labview/root/.ssh
    • sudo cp ~/.ssh/id_rsa* /srv/chroot/labview/root/.ssh/.
  3. Now log back into the chroot and run the SSH command once so that you can add localhost to the list of known hosts
    • sudo schroot -r -c lv
    • ssh root@localhost ls
    • When prompted to add localhost to the list of known hosts, say yes
    • exit
  4. At this point, you can run commands from within the LV chroot in the system outside the chroot by running a command of the form ssh <root_user>@localhost <command>. For instance, if I wanted to check the version of the Debian operation system on a Raspberry Pi I would run ssh pi@localhost cat /etc/debian_version. These commands can be run in a LabVIEW VI by using the System Exec VI, so now you have a way to execute commands outside of the LV chroot.

Thank you for reading my blog post, If you are interested in making a project but don’t have the right supplies, you can purchase the LabVIEW computing kit for the Raspberry Pi 2. This kit includes a copy of LabVIEW 2014 Home Edition and everything you will need to run LINX 3.0 and start working on projects. Please comment with any questions or comments you may have.

Share on FacebookTweet about this on TwitterShare on Google+Pin on PinterestShare on RedditShare on TumblrShare on LinkedInShare on StumbleUponEmail this to someone

About Author


  1. Hi,

    This might beyond the scope of this post, but what is this “SSH” that I keep seeing references to? Usually I hear people say you can “SSH into it” but that doesn’t mean anything to me. Could you explain it? Or write a post about it? 😉


    • It means establishing a secure shell (ssh) connection to a machine which runs an ssh daemon (a program that binds to a network port and listens to incoming connections). You will be using an ssh client for that, if you are trying to control a Raspberry Pi from a Windows computer you would need to download an SSH client(The most commonly used one is called PuTTY). This would allow you to remotely access your Raspberry Pi’s command line from your computer. What I am talking about in this post is installing an SSH client to the chroot so you could do the same thing from inside the chroot. This “chroot SSH cheat” allows LabVIEW to run commands and invoke executables using an SSH client installed inside the chroot. Does that make sense?

      • Hi Austin,

        Sorry for not responding sooner; but I think that makes sense. As you said, the SSH lets you essentially access the command line of one computer from a different computer? I guess normally you wouldn’t need to do that, but if LabVIEW has it’s own special directory, that would make sense why it needs access to the command line.

        It’s kinda weird that you need the program installed only on what needs special access and not anything installed on the directory you are accessing, but I guess the main OS doesn’t care if everything is all on the same storage space (since hard drive isn’t always applicable) or if you have a direct physical connection to what you are needing access to.

        Thanks for the quick response! (although mine wasn’t as quick)

Leave A Reply