Chroot SSH trick: Difference between revisions
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
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 like raspistill. | 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 like raspistill. | ||
1. Install an ssh client to your chroot: | 1. Install an ssh client to your chroot:<br> | ||
sudo schroot -r -c lv | * sudo schroot -r -c lv | ||
opkg update | * opkg update | ||
opkg install openssh-ssh | * opkg install openssh-ssh | ||
exit | * 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). | 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 | * ssh-keygen -t rsa<br> stick with the defaults when it prompts you, especially when it asks for the passphrase; we want an empty passphrase | ||
stick with the defaults when it prompts you, especially when it asks for the passphrase; we want an empty passphrase | * cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys | ||
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys | * sudo mkdir /srv/chroot/labview/root/.ssh | ||
sudo mkdir /srv/chroot/labview/root/.ssh | * sudo cp ~/.ssh/id_rsa* /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 | 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 | * sudo schroot -r -c lv | ||
ssh root@localhost ls | * ssh root@localhost ls | ||
When prompted to add localhost to the list of known hosts, say yes | * When prompted to add localhost to the list of known hosts, say yes | ||
exit | * 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. | 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. |
Revision as of 00:13, 8 July 2020
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 like raspistill.
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/id_rsa.pub >> ~/.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.