Skip to content

qbee-cli

What is qbee-cli?ΒΆ

The open source qbee-cli tool is a client library and a command line tool used to interact with qbee.io IoT/Linux device management platform. It has all remote access functionality build in and allows simple CLI based connections on Windows, Linux and Mac.

How to use qbee-cli?ΒΆ

The tool is invoked from the command line which makes it easy to use it in scripts as well.

export QBEE_EMAIL=<email>
export QBEE_PASSWORD=<password>

qbee-cli connect -d <deviceID> -t <target>[,<target> ...]

Where:

  • deviceID identifies to which device we want to connect (public key digest)
  • target defines a singe port forwarding target as <localPort>:<remoteHost>:<remotePort>
  • localPort is the local port on which tunnel will listen for connections/packets
  • remoteHost must be set to localhost
  • remotePort is the remote port on which tunnel will connect to on the device
$ ./qbee-cli -h
Usage: ./qbee-cli [global options] <command> [options] [<command> [options] ...]

Options:
  -l, --log-level LOG_LEVEL  Logging level: DEBUG, INFO, WARNING or ERROR.  [optional]  (default: INFO)  


Commands:
  connect - Connect to a device        
  devices - Device management commands 
  files   - Filemanager commands       
  login   - Login to Qbee.io           
  version - qbee-cli version. 

Port forwarding with qbee-cliΒΆ

Port forwarding, also known as tunneling, is a powerful feature that enhances the security and functionality of network connections. It is primarily used for secure remote access to systems, but it also provides a mechanism for creating encrypted tunnels between a local machine and a remote server. Port forwarding with qbee-cli involves redirecting network traffic from one port on a local machine to another port on a remote server enabling access to any network service running on the remote device over an encrypted and secure channel.

This article will show how to use qbee-cli to achieve quick access to any of your devices

  1. Get the latest version of qbee-cli from the releases page on GitHub

    Download using a command prompt

    Linux/MacOS

    curl -L -o qbee-cli https://github.com/qbee-io/qbee-cli/releases/latest/download/qbee-cli-<version>.[darwin|linux]-[amd64|arm64]
    chmod 755 qbee-cli
    

    Windows (cmd prompt):

    curl -L -o qbee-cli.exe https://github.com/qbee-io/qbee-cli/releases/latest/download/<version>/qbee-cli-<version>.windows-amd64
    
  2. Configure your terminal/prompt environment with your login credentials:

    Linux/MacOS:

    export QBEE_EMAIL=<myemail@example.com>
    export QBEE_PASSWORD=<mypassword>
    

    Windows (cmd prompt):

    set QBEE_EMAIL=<myemail@example.com>
    set QBEE_PASSWORD=<mypassword>
    
  3. Initiate port forwarding to any port on your device, eg. port 22 if you want to do ssh login

    qbee-cli connect -d <qbee-device-id> -t 2222:localhost:22
    
  4. Once the tunnel has been set up you can do the following from another terminal window

    ssh -l <ssh-login> -p 2222 localhost
    

qbee-cli integration with sshΒΆ

SSH is the de facto standard for securely accessing remote devices. With its wide feature set and proven security record it almost always has one or more applications in fleet management, from troubleshooting or configuring single devices to mass transfer of files. The basic use of SSH requires that the devices are accessible through its hostname or ip, something that is generally not case for internet connected devices due to security. However, qbee-cli can broker secure tunnels for ssh making access to your devices as simple as running an ssh command.

  1. Download qbee-cli and export your qbee credentials as described above

  2. Configure your ssh client config file to use a ProxyCommand for your qbee fleet:

    Linux/MacOS:

    ~/.ssh/config
    Host qbee-cli+*
        ProxyCommand qbee-cli connect -d $(echo %h | sed 's/qbee-cli+//') -t stdio:localhost:22
    

    Windows:

    ~/.ssh/config
    Host qbee-cli+*
        ProxyCommand powershell.exe -Command ".\qbee-cli.exe connect -d (echo %h).Replace('qbee-cli+','') -t stdio:localhost:22"
    
  3. Accessing can now be done using the following command

    ssh <ssh-login>@qbee-cli+<qbee-device-id>
    

    E.g.

    ssh pi@qbee-cli+ad9c4b4fef33ed1aade4eaa9d98f0cba6d633750c88a0e1890475f69df8bc8b2
    

    The qbee device id's are available in the qbee web based UI.