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. It is an alternative to qbee-connect.
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
The deviceID can be copied from the web UI.
$ ./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.
The following command maps a remote web server running on the edge device to you localhost port 8080:
qbee-cli connect -d <qbee-device-id> -t 8080:localhost:80
In the next paragraph you will see how to install it for Mac, Linux or Windows and how to configure the terminal environment depending if you are on Mac/Linux or Windows.
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 part will show how to use qbee-cli to achieve quick access to any of your devices
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
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>
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
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.
Download qbee-cli and export your qbee credentials as described above
Configure your ssh client config file to use a
ProxyCommand
for your qbee fleet:Linux/MacOS:
~/.ssh/configHost qbee-cli+* ProxyCommand qbee-cli connect -d $(echo %h | sed 's/qbee-cli+//') -t stdio:localhost:22
Windows:
~/.ssh/configHost qbee-cli+* ProxyCommand powershell.exe -Command ".\qbee-cli.exe connect -d (echo %h).Replace('qbee-cli+','') -t stdio:localhost:22"
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.