Rename file and add readme
authorPeng Li <seudut@gmail.com>
Fri, 22 Jun 2018 09:46:37 +0000 (17:46 +0800)
committerPeng Li <seudut@gmail.com>
Fri, 22 Jun 2018 10:11:44 +0000 (18:11 +0800)
README.md [new file with mode: 0644]
mqtt-client.py [deleted file]
suanzi-support
sztool [new file with mode: 0755]

diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..c13cdde
--- /dev/null
+++ b/README.md
@@ -0,0 +1,35 @@
+
+1. suanzi-support: a MQTT client, is a daemon running on remote embedded devices for remote debugging through ssh
+2. sztool : a local tool, help to get the forwarding port to be used to connect to remote device
+
+## Install
+- On embedded device
+    - run `./install.sh` to install the daemon and service file
+    - run `./add-user.sh` to create a user, used for remote ssh, named debug, and its password is hard2guess 
+
+## Usage
+To connect to remote embedded device, your should know the device's MAC address.
+
+1. run `./sztool -i 2acdeb93b285`
+
+where `2acdeb93b285` is the MAC address of rpdzkj board, which you want to
+connect. 
+
+2. If it succeed, it will return the forwarding port on `autossh.suanzi.ai`
+
+here is a sample
+```
+debian@[~/project/remote-ssh]>> ./sztool -i 2acdeb93b285
+Connected with result code 0
+2acdeb93b285-response 32171
+port is 32171
+run ssh debug@autossh.suanzi.ai -p 32171 to connect to  2acdeb93b285 device
+```
+
+3. run `ssh debug@autossh.suanzi.ai -p 32171`, then you can ssh to remote
+   device. The password is 'hard2guess', create in file `add-user.sh`
+
+
+## Note
+- After the port is generated, the ssh session alive time is 5 min (defined by ALIVE_TIME in suanzi-support). 
+It means after you get the forwarding port, but not run ssh to connect in 5 minutes. this ssh session will terminate.
diff --git a/mqtt-client.py b/mqtt-client.py
deleted file mode 100644 (file)
index 8a053d0..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env python2
-
-from subprocess import call, Popen, PIPE, STDOUT
-import paho.mqtt.client as mqtt
-import argparse
-
-MQTT_SERVER = 'mqtt.suanzi.ai'
-MQTT_PORT = 1883
-
-if __name__ == '__main__':
-    parser = argparse.ArgumentParser(description='Choose an avaiable port and run autossh.')
-    parser.add_argument('-i', '--id', dest='id', help='the unique id of remote machine, such as rpdzkj-080027a6f8dc, where the rpdzkj is the user, and 080027a6f8dc is the mac addres', required=True)
-    args = parser.parse_args()
-    id = args.id
-
-    def on_connect(client, userdata, flags, rc):
-        client.subscribe(id + "-response")
-        print("Connected with result code "+str(rc))
-        client.publish(id + '-request', 0)
-
-    def on_message(client, userdata, msg):
-        print(msg.topic+" "+str(msg.payload))
-        if msg.topic == id + '-response':
-            port = msg.payload
-            print 'port is', str(port)
-            print 'run ssh debug@autossh.suanzi.ai -p ' + str(port) + ' to connect to  ' + id + ' device'
-
-    client = mqtt.Client()
-    client.on_connect = on_connect
-    client.on_message = on_message
-    client.connect(MQTT_SERVER, MQTT_PORT, 60)
-    client.loop_forever()
index 183f6de..367f379 100755 (executable)
@@ -1,9 +1,5 @@
 #!/usr/bin/env python2
 
-# dependencies:
-#   1. pip install paho-mqtt
-#   2. apt-get install sshpass
-#
 from subprocess import call, Popen, PIPE, STDOUT
 import paho.mqtt.client as mqtt
 import shlex
diff --git a/sztool b/sztool
new file mode 100755 (executable)
index 0000000..8a053d0
--- /dev/null
+++ b/sztool
@@ -0,0 +1,32 @@
+#!/usr/bin/env python2
+
+from subprocess import call, Popen, PIPE, STDOUT
+import paho.mqtt.client as mqtt
+import argparse
+
+MQTT_SERVER = 'mqtt.suanzi.ai'
+MQTT_PORT = 1883
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(description='Choose an avaiable port and run autossh.')
+    parser.add_argument('-i', '--id', dest='id', help='the unique id of remote machine, such as rpdzkj-080027a6f8dc, where the rpdzkj is the user, and 080027a6f8dc is the mac addres', required=True)
+    args = parser.parse_args()
+    id = args.id
+
+    def on_connect(client, userdata, flags, rc):
+        client.subscribe(id + "-response")
+        print("Connected with result code "+str(rc))
+        client.publish(id + '-request', 0)
+
+    def on_message(client, userdata, msg):
+        print(msg.topic+" "+str(msg.payload))
+        if msg.topic == id + '-response':
+            port = msg.payload
+            print 'port is', str(port)
+            print 'run ssh debug@autossh.suanzi.ai -p ' + str(port) + ' to connect to  ' + id + ' device'
+
+    client = mqtt.Client()
+    client.on_connect = on_connect
+    client.on_message = on_message
+    client.connect(MQTT_SERVER, MQTT_PORT, 60)
+    client.loop_forever()