Creates a new command
$ cat ./script | ssh :create <name> -

:create will build and add a new command to your namespace with the given <name> using the script passed via STDIN. The - argument is required to inform the command to read from STDIN, as future versions may introduce an interactive mode.

Script format

Cmd expects a shell script with at least two shebang lines. The first line must be a special #!cmd line in this format:

#!cmd <base> [<package>...]

The first argument <base> is either alpine or ubuntu. The following optional arguments are packages available in their respective package repositories. Examples:

#!cmd alpine
#!cmd alpine bash curl
#!cmd ubuntu git build-essential

The next line must be a regular shebang line, defining either an interpreter for the rest of the script or a binary to run for the command. Examples:

#!cmd alpine bash
echo "Hello world"
#!cmd alpine curl


This simple example will install a package and use the binary as the interpreter. Our script will be the following:

#!cmd alpine speedtest-cli

Let’s create our speedtest command by redirecting a heredoc (an alternative to piping the text file) to the :create built-in command:

$ ssh :create speedtest - <<EOF
#!cmd alpine speedtest-cli
Creating command... done

We can then run and pass arguments to the command:

$ ssh speedtest --simple
Ping: 13.78 ms
Download: 552.79 Mbit/s
Upload: 126.91 Mbit/s

The output is a test of the Cmd infrastructure (not your local Internet connection). While not very practical, it demonstrates how we can run simple utilities entirely remotely.

Suggest Edits