SSH Tunnel
In this tutorial, we start and stop an SSH tunnel to an Edge Node via the Edge Builder CLI. This will cover how to:
- Initialise Edge Builder server components and CLI
- Add a node
- Start an SSH Tunnel to the node
- Stop the SSH Tunnel
- Remove the node
Initialise Edge Builder server components and CLI
To initialize the Edge Builder server components and CLI, complete the following steps:
-
Set up the environment as described in Tutorials Setup
-
SSH into the master node:
vagrant ssh master
-
Start the Edge Builder server components using the following command:
When the server components are up, you should see all server components up and running via thesudo edgebuilder-server up -a 192.168.56.10
docker ps
command:vagrant@master:~$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 54216df43569 iotechsys/dev-eb-controller:1.2.0.dev "./entrypoint.sh" 19 seconds ago Up 16 seconds 0.0.0.0:8085->8085/tcp, :::8085->8085/tcp, 0.0.0.0:50000-50100->50000-50100/tcp, :::50000-50100->50000-50100/tcp, 0.0.0.0:1022->22/tcp, :::1022->22/tcp eb-controller 28e962d77a00 chronograf:1.8.8-alpine "./custom-entrypoint…" 21 seconds ago Up 19 seconds 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp eb-chronograf 706d2b19acf4 postgres:alpine "./entrypoint.sh" 24 seconds ago Up 21 seconds 5432/tcp eb-db 83f4b4298be4 influxdb:1.8.1-alpine "./custom-entrypoint…" 24 seconds ago Up 21 seconds 0.0.0.0:8086->8086/tcp, :::8086->8086/tcp eb-influxdb c2981b5cbce7 portainer/portainer-ce:2.1.0-alpine "/portainer -H unix:…" 24 seconds ago Up 20 seconds 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp eb-portainer 5d4110072447 iotechsys/dev-eb-redis:1.2.0.dev "redis-server /etc/r…" 24 seconds ago Up 20 seconds 6379/tcp eb-redis 64901e67177b iotechsys/dev-eb-webssh:1.2.0.dev "wssh --address=0.0.…" 24 seconds ago Up 21 seconds 0.0.0.0:8989->8989/tcp, :::8989->8989/tcp eb-webssh 34811b289512 grafana/grafana:7.4.2 "/run.sh" 24 seconds ago Up 21 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp eb-grafana ac79f2182e86 iotechsys/dev-eb-salt-master:1.2.0.dev "/bin/sh -c 'sed -i …" 24 seconds ago Up 20 seconds 0.0.0.0:4505-4506->4505-4506/tcp, :::4505-4506->4505-4506/tcp, 0.0.0.0:8099->8099/tcp, :::8099->8099/tcp eb-salt-master 6583228fa467 kapacitor:1.5-alpine "/entrypoint.sh kapa…" 24 seconds ago Up 21 seconds 9092/tcp eb-kapacitor 6659e040296e vault:1.7.1 "./entrypoint.sh" 24 seconds ago Up 21 seconds 8200/tcp eb-vault
-
Log in to Edge Builder with the default user credentials using the following command:
You should see the following INFO message:edgebuilder-cli user login -u iotech -p EdgeBuilder123 -c "http://192.168.56.10:8085"
INFO: User "iotech" logged in successfully
-
Confirm that you have a valid license in the Vagrant project directory (
edgebuilder-vagrant
) - Add the license using the following command:
You should see the output similar to that shown below:
edgebuilder-cli license add -l DemoLicense -f /vagrant/EdgeBuilder_test_Evaluation.lic
INFO: License added successfully +-------------+--------------------------------------+---------------------------------+-----------+-----------+ | NAME | ID | FILENAME | MAX NODES | EXPIRY | +-------------+--------------------------------------+---------------------------------+-----------+-----------+ | DemoLicense | b65c2ba0-c78b-4031-aaf4-cc030d3d763d | EdgeBuilder_test_Evaluation.lic | 100 | unlimited | +-------------+--------------------------------------+---------------------------------+-----------+-----------+ INFO: Viewing 1 result(s)
Add a node
In this section of the tutorial, we will add a node to Edge Builder. It is accessible on 192.168.56.11
.
To add an edge node, complete the following steps:
-
Confirm that the example node configuration file is available using the
cat
command:Expected output:cat /vagrant/examples/single-node-config.json
{ "NodeConfig": [ { "name": "node1", "description": "virtual node 1", "nodeaddress": "192.168.56.11", "nodesshport": "22", "username" : "vagrant", "password" : "vagrant", "serveraddress": "192.168.56.10", "labels" : ["label1", "label2"] } ] }
-
Add the node to Edge Builder using the following command:
Expected output:edgebuilder-cli node add -f /vagrant/examples/single-node-config.json
INFO: SSH Node(s) added successfully: +-------+--------------------------------------+----------------+ | NODE | ID | LABELS | +-------+--------------------------------------+----------------+ | node1 | a87f7402-6fef-499f-985d-bcff30065709 | label1, label2 | +-------+--------------------------------------+----------------+ INFO: Viewing 1 result(s)
-
Confirm that the node has been added using the following command:
Expected output:edgebuilder-cli node view --all
INFO: Finding all nodes... INFO: *** Node View Results *** +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | NAME | ID | STATUS | DEBUG MODE | METRICS MODE | LABELS | DESCRIPTION | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ | node1 | a87f7402-6fef-499f-985d-bcff30065709 | Up | Off | Local | Virtual:VirtualBox, OSArch:amd64, Hostna | virtual node 1 | | | | | | | me:node1, CPUArch:x86_64, OSFamily:Debia | | | | | | | | n, Kernel:Linux, label1, Language:en_US, | | | | | | | | Timezone:UTC, CPUModel:11thGenIntel(R)C | | | | | | | | ore(TM)i7-11800H@2.30GHz, ProductName:Vi | | | | | | | | rtualBox, OSFinger:Ubuntu-20.04, UserNam | | | | | | | | e:root, Manufacturer:innotekGmbH, GroupN | | | | | | | | ame:root, label2 | | +-------+--------------------------------------+--------+------------+--------------+------------------------------------------+----------------+ INFO: Viewing 1 result(s)
Note
- The status of the node is initially shown as
Deploying
. After a few minutes, you can re-issue the command and the status will have changed toUp
- You can also use the
watch
command with thenode view
above to automatically track the status changes
- The status of the node is initially shown as
Start an SSH tunnel to the node
-
Start SSH tunneling using the following command:
Expected output:edgebuilder-cli node ssh -n node1 --start -w
INFO: WebSSH URL: http://192.168.56.10:8989?hostname=192.168.56.10&port=1022&username=chisel&password=STBUZWNoMTIz&command=ssh%20-o%20StrictHostKeyChecking=%27no%27%20-o%20ProxyCommand=%27chisel%20client%20localhost:50001%20stdio:22%27%20-i%20/home/chisel/a87f7402-6fef-499f-985d-bcff30065709.pem%20edgebuilder@node1;exit
-
In a browser, navigate to the WebSSH URL identified in the output of the previous command. The browser should display a terminal for
node1
- You can check the SSH tunnel for the node using the following command:
Expected output:
edgebuilder-cli node inspect -n node1 | grep SshTunnelUrl
"SshTunnelUrl": "http://192.168.56.10:8989?hostname=192.168.56.10&port=1022&username=chisel&password=STBUZWNoMTIz&command=ssh%20-o%20StrictHostKeyChecking=%27no%27%20-o%20ProxyCommand=%27chisel%20client%20localhost:50056%20stdio:22%27%20-i%20/home/chisel/92b70a0a-fade-42a2-9ea8-5669cdc3137e.pem%20edgebuilder@node1;exit",
Stop an SSH tunnel on a node
-
Stop the SSH tunnel using the following command:
Expected Output:edgebuilder-cli node ssh -n node1 --stop
INFO: Terminated SSH session with node1
-
You can confirm the removal off the SSH tunnel using the following command. You should see no output.
edgebuilder-cli node inspect -n node1 | grep SshTunnelUrl
Remove the node
To remove an edge node, complete the following steps:
-
Remove the edge node
node1
using the following command:Expected output:edgebuilder-cli node rm -n node1 -y
INFO: Processing nodes: ["node1"] INFO: Attempting to remove 1 node(s) INFO: Removal request for 1 node(s) accepted for processing by Edge Builder. Use 'node view' command to get updated status
-
Confirm that the node has been removed using the following command:
Expected output:edgebuilder-cli node view -n node1
INFO: Finding nodes: ["node1"] WARN: node "node1" not found WARN: 0 results to view