cours-snt/test-python-ssh/Readme.md

61 lines
1.8 KiB
Markdown
Raw Normal View History

2021-02-04 18:11:00 +00:00
# Python, web and SSH sandbox
2021-02-05 16:11:47 +00:00
For educational purpose only! None of this software is industry grade quality.
2021-02-04 18:11:00 +00:00
This repo got several parts :
## A python script
2021-02-05 16:11:47 +00:00
It run with uwsgi, see the dockerfile CMD line. You will need to change it to make it listen on a port.
2021-02-04 18:11:00 +00:00
Used to execute any python script in the `module` directory given a certain URL :
- /m1/f1 -> execute the f1 function from modules/m1.py
- /path/to/m2/f2 -> execute the f2 function from modules/path/to/m2.py
## SSH server
Allow student to connect via SSH or SFTP to add python files.
create a file named `users.txt`, then passwords and accounts will be generated by `entrypoint.sh`
TODO:
- install and configure the server
- configure chroot
- create the homes in modules directory
2021-02-05 16:11:47 +00:00
## A docker image
To bundle everything in one place.
This docker image is not a pretty one, we should split those services into several containers.
2021-02-11 14:08:34 +00:00
But that would be harder to run, so forget that.
Also, as this is poorly tested, the docker system make sure the environment is stable.
2021-02-04 18:11:00 +00:00
# Instructions
2021-02-05 16:11:47 +00:00
## Install docker
CF the interweb TODO
2021-02-04 18:11:00 +00:00
## Build the docker image
```
docker build . -t pythonsandbox
```
2021-02-11 14:08:34 +00:00
or pull it
2021-02-05 16:11:47 +00:00
```
TODO: send image to hub
```
2021-02-04 18:11:00 +00:00
## Run the docker image
```
2021-02-05 16:11:47 +00:00
docker run -it --network host --name pythonsandbox pythonsandbox
2021-02-04 18:11:00 +00:00
```
Or if you want to save student work outside of the container:
```
2021-02-05 16:11:47 +00:00
docker run -it --network host --name pythonsandbox -v "$(pwd)"/app/modules:/usr/share/app/modules pythonsandbox
2021-02-04 18:11:00 +00:00
```
And with user list file
```
2021-02-05 16:11:47 +00:00
docker run -it --network host --name pythonsandbox -v "$(pwd)"/app/modules:/usr/share/app/modules -v "$(pwd)"/app/users.txt:/usr/share/app/users.txt pythonsandbox
2021-02-04 18:11:00 +00:00
```
2021-02-05 16:11:47 +00:00
## Roadmap
2021-02-04 18:11:00 +00:00
## Example
With the files under `./app/modules` you can get the following URLs :
2021-02-05 16:11:47 +00:00
- http://localhost/mod1/func1_1
- http://localhost/mod1/func1_2
- http://localhost/myriem/mod2/func2_1
2021-02-04 18:11:00 +00:00