Manage machines from the CLI
Targeted commands for individual machines inside a workspace: SSH, logs, port forwarding, file copy, and plain ssh through a ProxyCommand.
m is short for machine. A machine is named by its UUID; -w <workspace-uuid> is optional for ssh, exec, logs, cp, sync and port-forward, because the machine is found without it.
List machines in a workspace#
easyenv machine list -w <workspace-uuid>
easyenv machine get <machine-uuid> -w <workspace-uuid>Start, stop, restart#
easyenv machine stop <machine-uuid> -w <workspace-uuid>
easyenv machine start <machine-uuid> -w <workspace-uuid>
easyenv machine restart <machine-uuid> -w <workspace-uuid>
easyenv machine extend <machine-uuid> -w <workspace-uuid> --duration 1hSSH and exec#
# Interactive shell
easyenv machine ssh <machine-uuid>
# Run one command; the exit code is the remote one
easyenv machine exec <machine-uuid> -- make test
# Print the ssh command instead of running it
easyenv machine ssh <machine-uuid> --dry-runThe connection goes through the EasyEnv connection broker, which the box dials outwards: no VPN, no mesh, no DNS and no public port. With password auth the CLI answers ssh's prompt itself, so sshpass is not needed; an ssh key on your profile works too (easyenv ssh-key add). easyenv machine password <machine-uuid> prints the password if you want it.
Plain ssh, scp and VS Code#
easyenv machine proxy works as an OpenSSH ProxyCommand. Add this to ~/.ssh/config and ordinary ssh, scp, rsync and VS Code Remote-SSH reach a box by name:
Host *.box.easyenv.io
User easyenv
ProxyCommand easyenv machine proxy %n
# then
ssh <machine-uuid>.box.easyenv.ioUse %n, not %h: OpenSSH lowercases %h, and machine UUIDs are mixed case. easyenv machine hostname <machine-uuid> prints the name to use.
Logs#
Show the box's bootstrap, status and cloud-init logs; -f keeps following them:
easyenv machine logs <machine-uuid>
easyenv machine logs <machine-uuid> -f
# A stack's output
easyenv stack logs <instance-uuid> -w <workspace-uuid>Port forward to localhost#
Bring a port on the machine to your laptop. Useful for hitting a dev server in your local browser without exposing it publicly. The command runs until you press Ctrl-C:
# Port 8080 on the machine to local 8080
easyenv machine port-forward <machine-uuid> 8080
# Local 9000 to port 8080 on the machine (LOCAL:REMOTE)
easyenv machine port-forward <machine-uuid> 9000:8080
# Several ports at once
easyenv machine port-forward <machine-uuid> 8080 5432forward and pf are aliases. --no-ssh carries a single port without an ssh client.
Copy files#
One side is local, the other is <machine>:/path:
# Push a local file to the machine
easyenv machine cp ./fixtures.sql <machine-uuid>:/tmp/fixtures.sql
# Pull a file off the machine
easyenv machine cp <machine-uuid>:/var/log/app.log ./app.log
# rsync a directory (--delete, --dry-run, --exclude)
easyenv machine sync ./src <machine-uuid>:/home/easyenv/app --exclude node_modulesWhen a machine will not connect#
easyenv diagnose <machine-uuid> walks the path to the box and stops at the first hop that fails: the backend, the access grant, the broker (is the box's agent connected), and port 22 inside the machine.
