mirror of
https://github.com/ghndrx/shellmate.git
synced 2026-02-10 06:45:02 +00:00
fix: SSH key permissions and configurable port
This commit is contained in:
11
Dockerfile
11
Dockerfile
@@ -15,13 +15,14 @@ COPY src/ src/
|
|||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
RUN pip install --no-cache-dir .
|
RUN pip install --no-cache-dir .
|
||||||
|
|
||||||
# Generate SSH host key
|
# Create user and directories
|
||||||
RUN mkdir -p /etc/shellmate && \
|
RUN useradd -m shellmate && \
|
||||||
ssh-keygen -t ed25519 -f /etc/shellmate/ssh_host_key -N ""
|
mkdir -p /etc/shellmate && \
|
||||||
|
chown shellmate:shellmate /etc/shellmate
|
||||||
|
|
||||||
# Run as non-root
|
# Switch to shellmate user and generate SSH key
|
||||||
RUN useradd -m shellmate
|
|
||||||
USER shellmate
|
USER shellmate
|
||||||
|
RUN ssh-keygen -t ed25519 -f /etc/shellmate/ssh_host_key -N ""
|
||||||
|
|
||||||
EXPOSE 2222
|
EXPOSE 2222
|
||||||
|
|
||||||
|
|||||||
@@ -78,10 +78,12 @@ async def handle_client(process: asyncssh.SSHServerProcess) -> None:
|
|||||||
|
|
||||||
async def start_server(
|
async def start_server(
|
||||||
host: str = "0.0.0.0",
|
host: str = "0.0.0.0",
|
||||||
port: int = 22,
|
port: int | None = None,
|
||||||
host_keys: list[str] = None,
|
host_keys: list[str] | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Start the SSH server."""
|
"""Start the SSH server."""
|
||||||
|
import os
|
||||||
|
port = port or int(os.environ.get("SHELLMATE_SSH_PORT", "2222"))
|
||||||
host_keys = host_keys or ["/etc/shellmate/ssh_host_key"]
|
host_keys = host_keys or ["/etc/shellmate/ssh_host_key"]
|
||||||
|
|
||||||
logger.info(f"Starting ShellMate SSH server on {host}:{port}")
|
logger.info(f"Starting ShellMate SSH server on {host}:{port}")
|
||||||
|
|||||||
Reference in New Issue
Block a user