Docs menu

SSH from VS Code or a terminal

Set up cloudflared once on your own laptop to SSH into a car or the pit PC from a terminal or VS Code Remote-SSH, with file copying and port forwarding.

SSH in the browser needs no setup, and it is enough for running commands. For editing the workspace in VS Code, copying files with scp or forwarding a port, set up a normal SSH client on your own laptop. The SSH connection still goes through Cloudflare, so the client hands it to Cloudflare’s cloudflared program through a ProxyCommand.

Set up

  1. Install cloudflared. Cloudflare’s downloads page has Windows, macOS and Linux builds; on macOS, brew install cloudflared also works. Open a new terminal afterwards so it is on your PATH.

  2. Add the devices to your SSH config. The file is ~/.ssh/config on macOS and Linux and C:\Users\<you>\.ssh\config on Windows; create it if it does not exist. Replace <device username> with the username from your team lead:

    Host rb1
        HostName ssh-rb1.sfuracerbot.ca
        User <device username>
        ProxyCommand cloudflared access ssh --hostname %h
    
    Host rb2
        HostName ssh-rb2.sfuracerbot.ca
        User <device username>
        ProxyCommand cloudflared access ssh --hostname %h
    
    Host pitpc
        HostName ssh-pitpc.sfuracerbot.ca
        User <device username>
        ProxyCommand cloudflared access ssh --hostname %h

    Each Host entry is the shortcut you type after ssh:

    Device Hostname Host entry SSH URL
    Car 1 racerbotcar-1 rb1 ssh-rb1.sfuracerbot.ca
    Car 2 racerbotcar-2 rb2 ssh-rb2.sfuracerbot.ca
    Pit PC racerbotpitpc pitpc ssh-pitpc.sfuracerbot.ca
  3. Connect:

    ssh rb1

    The first connection opens a browser tab for the Cloudflare Access sign-in. Sign in with your approved address, then enter the device password in the terminal.

Working when: the terminal shows a prompt on the device. Later connections skip the sign-in until the 24-hour session runs out.

VS Code

The Remote - SSH extension reads the same config file. Run Remote-SSH: Connect to Host from the command palette and pick rb1, rb2 or pitpc. VS Code then opens folders on that device, such as ~/racerbot-ws on a car, and its terminal runs there.

Troubleshooting

Symptom Cause Fix
websocket: bad handshake Your email address is not approved yet, or the browser signed in with a different account Sign in with the approved address; ask @it-services if it is new
cloudflared: command not found cloudflared is not installed, or the terminal was opened before it was Install it and open a new terminal
VS Code hangs at “Setting up SSH host” The sign-in tab opened behind another window and is waiting Find the browser tab, sign in, then retry

Limitations

  • Each laptop needs its own cloudflared and its own sign-in.
  • The ProxyCommand runs on every connection, so a laptop without cloudflared cannot use this config, even on the lab network.