change the default password
authorPeng Li <seudut@gmail.com>
Sat, 23 Jun 2018 01:55:18 +0000 (09:55 +0800)
committerPeng Li <seudut@gmail.com>
Sat, 23 Jun 2018 01:55:18 +0000 (09:55 +0800)
README.md
add-user.sh
sztool

index c13cdde..6618ee1 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,8 +4,8 @@
 
 ## Install
 - On embedded device
+    - run `./add-user.sh` to create a user, used for remote ssh, named debug, and its password is suanzikeji 
     - 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.
@@ -27,7 +27,7 @@ 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`
+   device. The password is 'suanzikeji', create in file `add-user.sh`
 
 
 ## Note
index f140ec5..aaff13f 100755 (executable)
@@ -1,11 +1,11 @@
 #!/bin/bash
 
-# Add a new user named debug, with password hard2guess for remote debug
+# Add a new user named debug, with password suanzikeji for remote debug
 # the suanzi-support daemon will be running as this user
 # run : sudo ./add-user.sh
 
 USER="debug"
-PASS="hard2guess"
+PASS="suanzikeji"
 
 echo "Create $USER user"
 useradd -m "${USER}" || exit 1
diff --git a/sztool b/sztool
index 8a053d0..82f547d 100755 (executable)
--- a/sztool
+++ b/sztool
@@ -6,26 +6,30 @@ import argparse
 
 MQTT_SERVER = 'mqtt.suanzi.ai'
 MQTT_PORT = 1883
+URI = 'debug@autossh.suanzi.ai'
+
+def on_connect(client, userdata, flags, rc):
+    id = client.id
+    client.subscribe(id + "-response")
+    print("Connected with result code "+str(rc))
+    client.publish(id + '-request', 0)
+
+def on_message(client, userdata, msg):
+    id = client.id
+    print(msg.topic+" "+str(msg.payload))
+    if msg.topic == id + '-response':
+        port = msg.payload
+        print 'run "ssh ' + URI + ' -p ' + str(port) + '" to connect to device (%s)' % id
 
 if __name__ == '__main__':
-    parser = argparse.ArgumentParser(description='Choose an avaiable port and run autossh.')
+    parser = argparse.ArgumentParser(description='Choose an avaiable port and run ssh.')
     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)
+    #parser.add_argument('connect',  help='list all connected devices')
+    #parser.add_argument('list',  help='list all connected devices')
     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.id = args.id
     client.on_connect = on_connect
     client.on_message = on_message
     client.connect(MQTT_SERVER, MQTT_PORT, 60)