Straight over SSH
Your Mac and iPhone connect to each server over SSH, as a terminal app does, with the server's identity remembered and checked every time. Nothing goes through our servers. Each device has its own SSH key, made in its Secure Enclave, so it can't be copied off the device.