/web_ssh

Interactive web terminals that can perform SSH session.

Primary LanguagePython

What is Web-SSH?

  • Web-SSH is web application of SSH client.
    You can connect your remote PC through SSH within a browser.
  • Another usage is interactive remote shell sessions with several other users on the same PC.
    It's super cool use case since you can debug a remote machine with several people (Only send a session link!).

Web-SSH Architecture

webssh (3)

Services Roles

  • Session Proxy
    Receiving all the sessions commands messages and return the outputs.
    Responsible for initialize each session environment.
  • Queues
    • STDOUT Queue Receiving STDOUT of the SSH Shell process and pass it back to Session Proxy service (and to the client).
    • Commands Queue Receiving commands from clients and pass them into SSH Runner consumer.
  • SSH Runner
    Runs each SSH Session as a sub-process.
    Fetching (Sampeling) the STDOUT of each process and pass it into the Queue.
    Rececing the commands and send them into the STDIN of each process.

Notes

  • Real Remote STDOUT The ssh session shell is opened in another process (inside docker container).
    We are pulling the STDOUT from this '/bin/shell; exit' process.
    It's possible also using Paramiko and skip this sub-process thing but it won't give us the PS1 and the REAL shell expreience.
  • Inner Container of each SSH Runner provide shell session isolation from the host (backend) environment.
    The sub-process we opened is actually a shell which run SSH client, so if we EXIT (and somehow skip the 'exit' commnad) the SSH session we have shell on the backend SSH Runner service.
    Think about a smart user that will exit the SSH session and run 'reboot' command. It will reset the whole Backend!
  • Shell Output Styling using ANSI escape code.
    We use Ansi esace codes parser in the client for styling the output (colors, fonts, etc).
  • Queues will be implemented with RabbitMQ. They pass through a Exchange that routing the messages by their types to the matching queue.