How to reliably & portably serialize binary information into POSIX shell

Problem context

I am trying to implement a job orchestrator whose agent/worker programs, connect to machines via an SSH session/shell. I would like to transfer (potentially binary) files to these agents (which could be needed for any sort of task).

Obviously, if ports can be configured in any way, then nc and a couple instructions could be executed. However, I'm trying to get something that works with the most restrictive setup.

Something I often do when working in this sort of setup (manually) is to serialize the file into Base64 or similar, and "paste" the data into the console session, something like:

echo -n "BINARY_BASE64_DATA" | base64 --decode > file_destination.file

I would like to implement something like this for the agent/worker I describe above.

Question

The crux of the question is on what tool to use to have the largest compatibility surface. Most Linux machines (even the bare-bones Docker/Vagrant images) seem to have base64 installed. However, FreeBSD does not seem to have this command pre-installed. I know I can install it with pkg or Ports, but I would like to use something out-of-the-box as much as possible.

I looked for something more POSIX/Unix-y, and found this: https://en.wikipedia.org/wiki/List_of_Unix_commands which says:

This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.

and has a long table of commands, of which the relevant ones would be uuencode and uudecode which are both listed as "mandatory".

On FreeBSD, I can see that it is installed out-of-the-box.

On my Ubuntu desktop, it is also present, although I don't know if it came out of the box or was installed as a dependency of something else I installed. However, inside an Ubuntu Vagrant box (generic/ubuntu2004, specifically), invoking uuencode shows the following message:

$ uuencode

Command 'uuencode' not found, but can be installed with:

apt install sharutils
Please ask your administrator.

On a Docker image I have based on Ubuntu 14.04, I get:

# uuencode
bash: uuencode: command not found
  1. Why does Ubuntu not include uuencode/uudecode out-of-the-box in all situations? Does this make it less POSIX/Unix-compliant?
  2. Is there another command that I am missing that provides the sort of functionality I am looking for, or should I just give up and demand that the worker/agent machine has the base64 binary installed to work with the orchestrator?

Why does Ubuntu not include uuencode/uudecode out-of-the-box in all situations?

Nothing requires Ubuntu, or any other system, to be Single Unix Specification compliant. Users that don't want sharutils might uninstall it. Especially on trimmed down images that have been optimized for space.

Realize that typically installed programs vary by platform. GNU coreutils provides base64, but BSD is unlikely to have GNU installed.

Is there another command that I am missing that provides the sort of functionality I am looking for

Portable shell scripts are difficult. base64 is relatively easy, and you already found minor differences after checking only 2 distros. Often scripting languages help with portability, like Python (base64) or Perl (MIME::Base64).

Part of Ansible's solution for doing anything portably is with Python, including slurping arbitrary files. Consider studying how Ansible is doing file transfers, if not use Ansible for the initial install. And regarding putting files, its wrapper around sftp is fairly portable and well tested.