Skip to content

Instantly share code, notes, and snippets.

@reubenmiller
Created January 13, 2025 12:08
Show Gist options
  • Save reubenmiller/d9dca804b745bd52102db4a165d8e1ff to your computer and use it in GitHub Desktop.
Save reubenmiller/d9dca804b745bd52102db4a165d8e1ff to your computer and use it in GitHub Desktop.
go-c8y-cli example on using ssh to forward a port from a device connected to Cumulocity using thin-edge.io
  1. Append the ssh config to your machine's ssh config file

    The following snippet creates

    cat <<EOT >> ~/.ssh/config
    Host rpi5-d83addab8e9f
            User root
            PreferredAuthentications publickey
            IdentityFile ~/.ssh/id_ed25519
            ServerAliveInterval 120
            StrictHostKeyChecking no
            UserKnownHostsFile /dev/null
            ProxyCommand c8y remoteaccess server --device %n --listen -
    EOT

    Note: You'll need to update the IdentityFile to use your SSH private key

  2. Set your c8y session

    set-session
    
  3. Connect to device using ssh and use port-forwarding to connect the remote's 127.0.0.1:1883 to your machine's port 1885

    ssh -L 1885:127.0.0.1:1883 rpi5-d83addab8e9f

    The host is the same name used from step 1.

  4. Use the forwarded port (on your machine)

    mosquitto_sub -h 127.0.0.1 -p 1885
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment