Unarchive this repo and big revamp

This commit is contained in:
Alexandre CATTEAU 2023-12-03 17:45:08 +01:00
parent 3ac7e300da
commit dc3605612a
4 changed files with 36 additions and 20 deletions

View File

@ -2,25 +2,17 @@
This is just a Systemd service unit for [WebSSH](https://github.com/huashengdun/webssh) web app. This is just a Systemd service unit for [WebSSH](https://github.com/huashengdun/webssh) web app.
Following the release of version 1.6.2, we now install it in an applicative container
[directly from PIP](https://github.com/huashengdun/webssh#quickstart).
### Files ### Files
* `webssh.service` is a Systemd units template for WebSSH. * `webssh.service` is a Systemd units template for WebSSH.
#### Installation #### Installation
* `install.sh` script copies the Systemd template to its destination, with the correct path (set in `variables.conf`). * `install.sh` script copies the Systemd template to its destination, with the correct path (set in `variables.conf`).
### Note ### Note
For this service to be correctly accessed through reverse proxy, you need the following parameters (Nginx example): For this service to be correctly accessed through reverse proxy, you need specific parameters. See
``` [official documentation](https://github.com/huashengdun/webssh#deployment).
location / {
proxy_pass http://localhost:8000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
}
```
### TODO ### TODO
* RAS * RAS

View File

@ -10,17 +10,41 @@ if [ -f $run_directory/.disabled ]; then
exit 0 exit 0
fi fi
if [ -f /usr/lib/python3.11/site-packages/webssh/handler.py ]; then
echo "Alter WebSSH configuration to remove SSH key passphrase from error message..."
if [[ $user != 'root' ]]; then
sudo sed -i -e "s/or wrong passphrase {} for decrypting it/or wrong passphrase for decrypting it/g"
else
sed -i -e "s/or wrong passphrase {} for decrypting it/or wrong passphrase for decrypting it/g"
fi
else
echo "WARNING: Could not find webssh directory! Could be due to major Python upgrade, or you not using PIP package."
fi
if [ ! -f $keyfile ] || [ ! -f $certfile ]; then
echo "Creating self-signed certificate for web server..."
if [[ $user != 'root' ]]; then
sudo openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out $certfile -keyout $keyfile \
-subj "/C=/ST=/L=/O=/OU=/CN="
else
openssl req -newkey rsa:4096 -x509 -sha256 -days 999 -nodes -out $certfile -keyout $keyfile \
-subj "/C=/ST=/L=/O=/OU=/CN="
fi
fi
echo "Copying WebSSH unit to system directory..." echo "Copying WebSSH unit to system directory..."
if [[ $user != 'root' ]]; then if [[ $user != 'root' ]]; then
sudo cp webssh.service /etc/systemd/system/ sudo cp webssh.service /etc/systemd/system/
sudo sed -i -e "s:PH_PATH:$webssh_path:g" /etc/systemd/system/webssh.service
sudo sed -i -e "s:PH_ADDR:$address:g" /etc/systemd/system/webssh.service sudo sed -i -e "s:PH_ADDR:$address:g" /etc/systemd/system/webssh.service
sudo sed -i -e "s:PH_PORT:$port:g" /etc/systemd/system/webssh.service sudo sed -i -e "s:PH_PORT:$port:g" /etc/systemd/system/webssh.service
sudo sed -i -e "s:PH_CRT:$certfile:g" /etc/systemd/system/webssh.service
sudo sed -i -e "s:PH_KEY:$keyfile:g" /etc/systemd/system/webssh.service
else else
cp webssh.service /etc/systemd/system/ cp webssh.service /etc/systemd/system/
sed -i -e "s:PH_PATH:$webssh_path:g" /etc/systemd/system/webssh.service
sed -i -e "s:PH_ADDR:$address:g" /etc/systemd/system/webssh.service sed -i -e "s:PH_ADDR:$address:g" /etc/systemd/system/webssh.service
sed -i -e "s:PH_PORT:$port:g" /etc/systemd/system/webssh.service sed -i -e "s:PH_PORT:$port:g" /etc/systemd/system/webssh.service
sed -i -e "s:PH_CRT:$certfile:g" /etc/systemd/system/webssh.service
sed -i -e "s:PH_KEY:$keyfile:g" /etc/systemd/system/webssh.service
fi fi
echo "Reloading Systemd..." echo "Reloading Systemd..."
if [[ $user != 'root' ]]; then if [[ $user != 'root' ]]; then

View File

@ -2,6 +2,7 @@
# Copy this file as variables.conf, with the correct values # Copy this file as variables.conf, with the correct values
webssh_path= address=0.0.0.0
address=127.0.0.1 port=4433
port=8000 certfile=/etc/ssl/cert.crt
keyfile=/etc/ssl/private/cert.key

View File

@ -3,8 +3,7 @@ Description=Run Python webssh web app
After=network.target After=network.target
[Service] [Service]
User=www-data ExecStart=/usr/bin/wssh --address='PH_ADDR' --sslport=PH_PORT --certfile='PH_CRT' --keyfile='PH_KEY'
ExecStart=/usr/bin/python3 PH_PATH --address='PH_ADDR' --port=PH_PORT
[Install] [Install]
WantedBy=default.target WantedBy=default.target