Django + paramiko achieve webshell

Explanation

Based on python3.7 + django-webshell django 2.2.3 implementation, the project addresses: https://github.com/leffss/django-webssh . Reference Django-webshell . On the basis of the reference projects do some optimization: new front page refresh confirmation page (refresh will cause websocket disconnected), the back-end code optimization paramiko thread creation, recording command and recording the results. Interested students may be slightly modified to integrate their fortress machine on this basis.

Required technology:

  • websocket currently on the market are based on the most webssh websocket agreement completed
  • django-channels django third-party plug-ins provide support for django websocket
  • An analog front end shell library terminal xterm.js
  • A bank on the lower package ssh2 paramiko python

How to integrate the technology needed?

  1. xterm.js shell browser of the analog terminal, monitor user input through a user input uploads the websocket to django
  2. django received user upload, upload content on the front page the user input through paramiko established ssh channel to a remote server to perform
  3. paramiko processing results back to the remote server django
  4. django paramiko results returned back to the user via websocket
  5. xterm.js django received data and writes it to return to the front page of

flow chart

start up

pip3 install -r requirements.txt
cd django-webssh/webssh/
python3 manage.py runserver 0.0.0.0:8000

Access: http://127.0.0.1:8000

Preview






Guess you like

Origin www.cnblogs.com/leffss/p/11249653.html