Eccentric Developments


Remote machine development

I have been doing some web development on remote computers, both real hardware and virtual machines. And for some of those projects, apart from having to install several services (redis, mongo, a vpn), hosts file entries have to be configured.

Usually what I've been doing is having a mix of configurations shared between my computer and the remote machine, which is not ideal as I want to maintain them as isolated from each other as possible. After some experimentation, I came to the following setup.

Local machine

  • Visual Studio Code with the Remote - SSH extension
  • Firefox or Chrome browser
  • SSH public/private keys

Remote machine

  • SSH auto login using the local machine SSH public key
  • All needed services: redis, mongodb, nginx, etc.
  • Dev tools: tmux, node.js, rust, and others
  • Any other configurations: hosts, vpn.

When it is time to start development, the first thing to do is, connect to the remote machine and, using tmux, start all services and vpn connections; tmux will keep them open even if the ssh session disconnects. In Visual Studio Code, connect to the remote machine using SSH, using the remote ssh extension.

Next is the most important part:

  1. Initiate a proxy session with the remote machine using:

    ssh -D 1337 -qCN <remote_machine>
    

    this acts as a SOCKS proxy.

  2. Open Firefox or Chrome and change the proxy configuration. SOCKS v5 hosts is

    127.0.0.1:1337
    

    and enable DNS proxy over it.

If the remote application responds to a particular domain or hostname, i.e. www.demo.com, the configuration can be added in the remote machine hosts file and be used from the local machine with no local changes. Same for all internal applications that would otherwise be only accessible through the vpn connections, will also be available through the configured browser.

This configuration allows me to keep the local machine as isolated as possible, without having to connect to the remote machine using vnc or remote desktop, which is usually slow and generally a not-so-great dev experience. If you don't have a dev server or don't want to configure one, ubuntu multipass is a great option to do all this, using your current computer.