Added webdav.

This commit is contained in:
2025-03-29 07:13:23 +01:00
parent fe1b3d6d19
commit 29139d5d0c
54 changed files with 1022 additions and 669 deletions
+13 -4
View File
@@ -1,7 +1,8 @@
import asyncio
import asyncssh
import os
import asyncssh
# SSH Server Configuration
HOST = "0.0.0.0"
PORT = 2225
@@ -9,6 +10,7 @@ USERNAME = "user"
PASSWORD = "password"
SHELL = "/bin/sh" # Change to another shell if needed
class CustomSSHServer(asyncssh.SSHServer):
def connection_made(self, conn):
print(f"New connection from {conn.get_extra_info('peername')}")
@@ -22,6 +24,7 @@ class CustomSSHServer(asyncssh.SSHServer):
def validate_password(self, username, password):
return username == USERNAME and password == PASSWORD
async def custom_bash_process(process):
"""Spawns a custom bash shell process"""
env = os.environ.copy()
@@ -29,7 +32,12 @@ async def custom_bash_process(process):
# Start the Bash shell
bash_proc = await asyncio.create_subprocess_exec(
SHELL, "-i", stdin=asyncio.subprocess.PIPE, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, env=env
SHELL,
"-i",
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
env=env,
)
async def read_output():
@@ -48,6 +56,7 @@ async def custom_bash_process(process):
await asyncio.gather(read_output(), read_input())
async def start_ssh_server():
"""Starts the AsyncSSH server with Bash"""
await asyncssh.create_server(
@@ -55,14 +64,14 @@ async def start_ssh_server():
host=HOST,
port=PORT,
server_host_keys=["ssh_host_key"],
process_factory=custom_bash_process
process_factory=custom_bash_process,
)
print(f"SSH server running on {HOST}:{PORT}")
await asyncio.Future() # Keep running
if __name__ == "__main__":
try:
asyncio.run(start_ssh_server())
except (OSError, asyncssh.Error) as e:
print(f"Error starting SSH server: {e}")