remote_shell

Remote shell through nats written by rust. The use scenarios include iot device with no fixed ip, home computer behind local network, etc. with remote shell installed on slave machine, you can access from host like normal ssh process.

step 1: Start golang nats message queue:

nats-server --user test --pass test

step 2: Revise conf string in .env :

``` SLAVEID= yourid

nats or pass

TRANS=pass

if use pass(https://github.com/wangmarkqi/pass_ball)

PASS_URL = http://192.168.177.1:8084

if use nats(famous golang msg queue)

NATSURL = localhost NATSACCOUNT = username NATS_PWD= password ``` SLAVEID is id for slave, the slave only response for request which specified by 'use' command.

When TRANS=nats, SLAVEID field is only needed for slave side. NATS_URL is nats host,and the account,password is auth method provided by nats-io. When TRANS=pass,SLAVEID should not conflict with topics in pass msg queue,better use uuid as SLAVEID or any string you can sure will not duplicate.

step 3: Start slave by run slave::slave_dispatch::dispatch();

To use remote shell, 2 kinds of binary are needed to be build, the salve and the host. Step 3 is for slave side.

step 4: Start host by run host::shell::run_shell();

To use remote shell, 2 kinds of binary are needed to be build, the salve and the host. Step 4 is for host side.

step 5: Stared with command "use"

First specify slave id by "use " and send command as normal shell,like "cd /home" etc.

Others:

The remoteshell use color scheme might result in errors on win10 cmd or powershell. But test is passed when use cmder instead.

The buildin function include:

use

This command will specify the slave you want to control.You should run step3 on slave pc and config the slave id in the .env file. This salve_id (use arg) should be same with id in the .env file.

example: use remote

wait

If true,the shell should demo result immediately.If false,the order is sent async and wait no result, you should consider false when run damon application or forever loop programme.

example: wait true/false

send

Send local file to remote.

example: send C://test.txt /home/test.txt

rec

Receive file from remote.

example: rec C://test1.txt /home/test2.txt

sendall allowextention/optional

Send local directory and all sub-dirs,sub-files to remote. Command send_all is the combinations of command send. If suffix given, the file with given suffix will be sent,otherwise all files will be sent. However, NATS message queue limit default transfer size 1m, any file transfer beyond size will fail.

example: sendall C://test /home/test example: sendall C://test /home/test py;html;js

restart

Will restart remote computer.This command is sent by async message pub channel and act as the final rescue when shell crash. Pay attention to restart remote_shell automatically after system reboot.

example: restart