If you have installed the remoteit CLI or Desktop package on a Linux PC/device or Mac, you can use the following commands to make peer to peer connections to other devices at the console. This may be useful if you wish to write scripts to make connections between Devices.
To make a connection to a Service, you will need to have the Service ID.
In this example, the Service ID is 80:00:00:05:3A:00:xx:xx
sudo remoteit connection add --id 80:00:00:05:3A:00:xx:xx
You can then use the
sudo remoteit status
command to check the assigned localhost port for each connection.
pi@raspberrypi:~ $ sudo remoteit status
✓ Fetching status
Username: f-------@-------.com
Device:
UID | Name | Type | Status | Address
------------------------------------------------------------------------------------------------------------------------------
80:00:00:00:01:0C:xx:xx | | device | online | 127.0.0.1:65535
Services:
UID | Name | Type | Status | Address | Enabled
-----------------------------------------------------------------------------------------------------------------------------------------
80:00:00:00:01:0C:xx:xx | ssh | | online | 127.0.0.1:22 | true
80:00:00:00:01:0C:xx:xx | http | | online | 127.0.0.1:80 | true
80:00:00:00:01:0C:xx:xx | remoteit admin | | online | 127.0.0.1:29999 | true
Connections:
UID | Name | Type | Status | Address | Enabled | P2P | Failover
----------------------------------------------------------------------------------------------------------------------------------------------------------------
80:00:00:05:3A:00:xx:xx | b8_27_eb_e4_0d_aa-ssh-22 | unknown | ready | 127.0.0.1:33001 | true | false | false
pi@raspberrypi:~ $
To pick off the IP and port for use in a script, you can use the following approach.
sudo remoteit connection add --id 80:00:00:05:3A:00:xx:xx
connect=$(sudo remoteit status | grep 80:00:00:05:3A:00:xx:xx | awk '{ print $10 }')
echo $connect
ip=$(echo $connect | awk -F":" '{ print $1 }')
echo $ip
port=$(echo $connect | awk -F":" '{ print $2 }')
echo $port
This gives:
pi@raspberrypi:~ $ sudo remoteit connection add --id 80:00:00:05:3A:00:xx:xx
✓ ADD in progress ...
✓ NEXT-ACTION: run 'sudo remoteit status' for status
pi@raspberrypi:~ $ connect=$(sudo remoteit status | grep 80:00:00:05:3A:00:xx:xx | awk '{ print $10 }')
pi@raspberrypi:~ $ echo $connect
127.0.0.1:33001
pi@raspberrypi:~ $ ip=$(echo $connect | awk -F":" '{ print $1 }')
pi@raspberrypi:~ $ echo $ip
127.0.0.1
pi@raspberrypi:~ $ port=$(echo $connect | awk -F":" '{ print $2 }')
pi@raspberrypi:~ $ echo $port
33001
pi@raspberrypi:~ $
All commands for connections
Run the following command to see all possible commands that can be used to manage connections.
sudo remoteit connection help
pi@raspberrypi:~ $ sudo remoteit connection help
Connection
━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Usage │ remoteit connection COMMAND(s) --FLAG(s)
━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Commands │ add ─ Create a local connection to a device in remote.it
│ remove ─ Remove a local connection to a device in remote.it
│ modify ─ Modify a local connection to a device in remote.it
│ connect ─ Triggers a connect for a local connection
│ disconnect ─ Triggers a disconnect for a local connection
│
──────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Flags │ Name │ Type │ Required │ Default │ Description
│ ───────────────────┼────────┼──────────┼─────────┼───────────────────────────────────────────────────────────────────
Globals │ --json │ bool │ false │ false │ Enables JSON output
│ --j │ bool │ false │ false │ Enables JSON output, alias for --json
│ --verbose │ bool │ false │ false │ Enables verbose output
│ --v │ bool │ false │ false │ Enables verbose output, alias for --verbose
│ --config │ string │ false │ │ Config file
│ --manufacture-id │ int │ false │ -1 │ Overrides the ManufactureID sent to the backend
│ --platform-version │ int │ false │ -1 │ Overrides the PlatformVersion sent to the backend
│ --authhash │ string │ false │ │ Allows operating based on '--authhash', no elevated permissions
──────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Examples │ remoteit connection add [FLAGS]
│ remoteit connection remove [FLAGS]
│ remoteit connection modify [FLAGS]
│
pi@raspberrypi:~ $
Returning the status in JSON format
If you are using a higher level language such as Python, you may find it easier to parse the status block information if it is returned as JSON. Use the following command:
sudo remoteit status --json