Sign inSign up

ericvh/cpu

By ericvh

•Updated about 4 years ago

CPU as a service: Remote login with back-mount of origin file system.

Image
1

235

ericvh/cpu repository overview

⁠cpu

CircleCI Go Report Card GoDoc License

This repo is an implementation the Plan 9 cpu command, both client and server, for Linux. More detail is available in the CPU chapter of the LinuxBoot book⁠. Unlike the Plan 9 command, this version uses the ssh protocol for the underlying transport. It includes features familiar to ssh users, such as support for the ssh config file.

⁠Overview

The cpu command lets you log in from a local system to a remote system and see some or all of the files (how much is up to you) from the local system.

This is wonderfully convenient for embedded systems programmers. Because some or all the files can come from your local machine, including binaries, the only thing you need installed on the remote machine is the cpu daemon itself.

⁠Docker how-to

The docker image includes both the cpud (server) and cpu (client) commands. In the container, you only have access to date and cat commands, but that is enough to get the idea.

You will need keys. You can either use your own SSH keys that you use for other things, for example:

export KEY=~/.ssh/id_rsa
export KEY=~/.ssh/a_special_key_for_this_docker

or generate one and use it.

ssh-keygen -f key -t rsa  -P ""
export KEY=`pwd`/key

NOTE! The name KEY is not required. Instead of KEY, you can use any name you want, as long as you use it in the docker command below.

To start the cpud, you need docker installed. Once that is done, you need to create a docker network and start the daemon, with public and private keys. The --mount option allows docker to provide the keys, using a bind mount for both the private and public key. That is how we avoid storing keys in the container itself.

docker network create cpud
docker run -i -t -v $KEY:/.ssh/identity -v $KEY.pub:/key.pub --privileged -v /tmp:/tmp -e PWD=/ --rm --network cpud --name cpud -p 17010:17010 ericvh/cpu:latest

Then you can try running a command or two:

docker exec -it  cpud  /bin/cpu localhost /bin/date

Remember, this cpu command is running in the container. You need to use the name /key in the container, not $KEY.

To see the mounts:

docker exec -it  cpud  /bin/cpu -key /key localhost /bin/cat /proc/mounts

Tag summary

Content type

Image

Digest

sha256:12b33521d…

Size

10.4 MB

Last updated

about 4 years ago

docker pull ericvh/cpu