Skip to content

Instantly share code, notes, and snippets.

@gwpl
Last active December 18, 2023 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwpl/c61ddd6b0466183d658357d391e0effd to your computer and use it in GitHub Desktop.
Save gwpl/c61ddd6b0466183d658357d391e0effd to your computer and use it in GitHub Desktop.
Wish for p2p "give access to my terminal and me approve commands" tool

I with a tool that would allow to give easy like "remotedesktop" access, but for terminal access, with :

  • build in , review of each command to execute on client side
  • review of outputs of commands being send
  • option to allow to stream output of command without review
  • automatic report generation in Markdown with proper codeblocks (generated on both sides)
  • easy p2p connections behind nats like croc , toss/catch , syncthing.

So basically I would love tool to help people troubleshoot linux issues, like croc or toss but two easily establish tcp-ip connection(s) (or ideally also udp) to run over it ssh/mosh terminal, with user approvals for execution of commends. and format output so file is nice markdown report.

Imagine flow, on other persons computer:

$ give_terminal_access x_example_local_report.md # of course --always-stream , will auto-approve commands and display on terminal what's going on.

give pass phrase:
blue foo flying jar bar always at zoo

### connection established 2012-12-12 12:12:12

### $ `cat /etc/hosts`

> Do you agree to execute this command: [(e)xecute and give outputs to review/edit before sending / execute and (s)tream outputs as they go / (d)eny ]

> e

> `Opens output with `$EDITOR` , user saves and exits editor , then output is send...`

User did not edit output, output send:

```
127.0.0.1       localhost
::1     localhost
```

### `$ sudo journal ctl`

> Detected "sudo" on beginning of command, we will ask you locally to provide sudo and do not disclose to other side.

> Do you agree to execute this command: [(e)xecute and give outputs to review/edit before sending / execute and (s)tream outputs as they go / (d)eny ]

> s

sudo password: <provided_not_visible>

streaming response:

```
Aug 15 12:56:53 localhost systemd[1]: Started Process Accounting Daemon.
Aug 15 14:24:42 localhost systemd[1]: Starting Cleanup of Temporary Directories...
Aug 16 11:46:38 localhost kernel: [UFW BLOCK] IN=eth0 OUT= MAC=00:0c:12:b4:da:11:00:50:56:f5:00:08:08:00 SRC=10.0.0.4 DST=10.0.0.12 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=29567 DF PROTO=TCP SPT=34230 DPT=22 WINDOW=29200 RES=0x00 SYN URGP=0 
Aug 17 00:00:18 localhost systemd[1]: logrotate.service: Succeeded.
Aug 17 18:26:39 localhost systemd[1]: Started Daily rotation of log files.
Aug 18 09:01:47 localhost systemd[1]: Started Session c1 of user guest.
(...)
```

P.S.: Regarding using ``` backticks in markdown : https://gist.github.com/gwpl/52bb57d05c0a5b21c4abe1e5e206b5f1 , as such tool would need to detect if there are backticks at included codeblocks and surround them with sufficiently long sequence of backticks.

P.P.S. Apart from "(s)treaming", one could have one more option "(t)ty terminal", Providing pseudo-terminal (PTY) support for terminal style terminal to  interactive tools (think of vim,htop,iotop,mc,screen,tmux... . To maintain report clarity, people on both sides could via key combination "add asciiart screenshot to report" i.e. codeblock with current terminal viewport, as they use the app.

P.P.P.S some links found afterwards , that maybe good enough alternatives in mean time: https://httprelay.io/ or code of Rust multiplexer https://github.com/zellij-org/zellij maybe useful for PTY.

connection established 2012-12-12 12:12:12

$ cat /etc/hosts

Do you agree to execute this command: [(e)xecute and give outputs to review/edit before sending / execute and (s)tream outputs as they go / (d)eny ]

e

Opens output with $EDITOR , user saves and exits editor , then output is send...

User did not edit output, output send:

127.0.0.1       localhost
::1     localhost

$ sudo journal ctl

Detected "sudo" on beginning of command, we will ask you locally to provide sudo and do not disclose to other side.

Do you agree to execute this command: [(e)xecute and give outputs to review/edit before sending / execute and (s)tream outputs as they go / (d)eny ]

s

sudo password: <provided_not_visible>

streaming response:

Aug 15 12:56:53 localhost systemd[1]: Started Process Accounting Daemon.
Aug 15 14:24:42 localhost systemd[1]: Starting Cleanup of Temporary Directories...
Aug 16 11:46:38 localhost kernel: [UFW BLOCK] IN=eth0 OUT= MAC=00:0c:12:b4:da:11:00:50:56:f5:00:08:08:00 SRC=10.0.0.4 DST=10.0.0.12 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=29567 DF PROTO=TCP SPT=34230 DPT=22 WINDOW=29200 RES=0x00 SYN URGP=0 
Aug 17 00:00:18 localhost systemd[1]: logrotate.service: Succeeded.
Aug 17 18:26:39 localhost systemd[1]: Started Daily rotation of log files.
Aug 18 09:01:47 localhost systemd[1]: Started Session c1 of user guest.
(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment