Setting up and managing servers is a headache. You need to start the server process, monitor it throughout its
life span, make sure it doesn’t hog up memory over time (or restart it if it does), make sure it comes up
automatically after reboots, manage user permissions and make sure everything remains secure. Enter zero-deploy.

Zero-deploy RPyC does all of the above, but doesn’t stop there: it allows you to dispatch an RPyC server on a machine
that doesn’t have RPyC installed, and even allows multiple instances of the server (each of a different port),
while keeping it all 100% secure. In fact, because of the numerous benefits of zero-deploy, it is now considered
the preferred way to deploy RPyC.

There’s a lot of detail here, of course, but the good thing is you don’t have to bend your head around it –
it requires only two lines of code:

fromrpyc.utils.zerodeployimportDeployedServerfromplumbumimportSshMachine# create the deploymentmach=SshMachine("somehost",user="someuser",keyfile="/path/to/keyfile")server=DeployedServer(mach)# and now you can connect to it the usual wayconn1=server.classic_connect()printconn1.modules.sys.platform# you're not limited to a single connection, of courseconn2=server.classic_connect()printconn2.modules.os.getpid()# when you're done - close the server and everything will disappearserver.close()

The DeployedServer class can be used as a context-manager, so you can also write:

You can deploy multiple instances of the server (each will live in a separate temporary directory), and create
multiple RPyC connections to each. They are completely isolated from each other (up to the fact you can use
them to run commands like ps to learn about their neighbors).

Zero-deploy is ideal for use-once, on-demand servers. For instance, suppose you need to connect to one of your
machines periodically or only when a certain event takes place. Keeping an RPyC server up and running at all times
is a waste of memory and a potential security hole. Using zero-deploy on demand is the best approach for
such scenarios.

Zero-deploy relies on SSH for security, in two ways. First, SSH authenticates the user and runs the RPyC server
under the user’s permissions. You can connect as an unprivileged user to make sure strayed RPyC processes can’t
rm-rf/. Second, it creates an SSH tunnel for the transport, so everything is kept encrypted on the wire.
And you get these features for free – just configuring SSH accounts will do.