mirror of
https://github.com/Monadical-SAS/cubbi.git
synced 2025-12-21 12:49:07 +00:00
fix(ssh): do not enable ssh automatically
This commit is contained in:
@@ -87,6 +87,9 @@ mcx https://github.com/username/repo --mcp github
|
|||||||
|
|
||||||
# Shorthand with an initial command
|
# Shorthand with an initial command
|
||||||
mcx . --run "apt-get update && apt-get install -y my-package"
|
mcx . --run "apt-get update && apt-get install -y my-package"
|
||||||
|
|
||||||
|
# Enable SSH server in the container
|
||||||
|
mcx --ssh
|
||||||
```
|
```
|
||||||
|
|
||||||
## Driver Management
|
## Driver Management
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ def create_session(
|
|||||||
gid: Optional[int] = typer.Option(
|
gid: Optional[int] = typer.Option(
|
||||||
None, "--gid", help="Group ID to run the container as (defaults to host user)"
|
None, "--gid", help="Group ID to run the container as (defaults to host user)"
|
||||||
),
|
),
|
||||||
|
ssh: bool = typer.Option(False, "--ssh", help="Start SSH server in the container"),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create a new MC session
|
"""Create a new MC session
|
||||||
|
|
||||||
@@ -267,6 +268,7 @@ def create_session(
|
|||||||
run_command=run_command,
|
run_command=run_command,
|
||||||
uid=target_uid,
|
uid=target_uid,
|
||||||
gid=target_gid,
|
gid=target_gid,
|
||||||
|
ssh=ssh,
|
||||||
)
|
)
|
||||||
|
|
||||||
if session:
|
if session:
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ class ContainerManager:
|
|||||||
run_command: Optional[str] = None,
|
run_command: Optional[str] = None,
|
||||||
uid: Optional[int] = None,
|
uid: Optional[int] = None,
|
||||||
gid: Optional[int] = None,
|
gid: Optional[int] = None,
|
||||||
|
ssh: bool = False,
|
||||||
) -> Optional[Session]:
|
) -> Optional[Session]:
|
||||||
"""Create a new MC session
|
"""Create a new MC session
|
||||||
|
|
||||||
@@ -163,6 +164,7 @@ class ContainerManager:
|
|||||||
mcp: Optional list of MCP server names to attach to the session
|
mcp: Optional list of MCP server names to attach to the session
|
||||||
uid: Optional user ID for the container process
|
uid: Optional user ID for the container process
|
||||||
gid: Optional group ID for the container process
|
gid: Optional group ID for the container process
|
||||||
|
ssh: Whether to start the SSH server in the container (default: False)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
# Validate driver exists
|
# Validate driver exists
|
||||||
@@ -188,6 +190,9 @@ class ContainerManager:
|
|||||||
if gid is not None:
|
if gid is not None:
|
||||||
env_vars["TARGET_GID"] = str(gid)
|
env_vars["TARGET_GID"] = str(gid)
|
||||||
|
|
||||||
|
# Set SSH environment variable
|
||||||
|
env_vars["MC_SSH_ENABLED"] = "true" if ssh else "false"
|
||||||
|
|
||||||
# Pass API keys from host environment to container for local development
|
# Pass API keys from host environment to container for local development
|
||||||
api_keys = [
|
api_keys = [
|
||||||
"OPENAI_API_KEY",
|
"OPENAI_API_KEY",
|
||||||
@@ -596,6 +601,7 @@ class ContainerManager:
|
|||||||
run_command=run_command, # Store the command
|
run_command=run_command, # Store the command
|
||||||
uid=uid,
|
uid=uid,
|
||||||
gid=gid,
|
gid=gid,
|
||||||
|
ssh=ssh, # Store SSH setting
|
||||||
)
|
)
|
||||||
|
|
||||||
# Save session to the session manager
|
# Save session to the session manager
|
||||||
|
|||||||
@@ -45,9 +45,13 @@ chown $MC_USER_ID:$MC_GROUP_ID /home/mcuser
|
|||||||
mkdir -p /app
|
mkdir -p /app
|
||||||
chown $MC_USER_ID:$MC_GROUP_ID /app
|
chown $MC_USER_ID:$MC_GROUP_ID /app
|
||||||
|
|
||||||
# Start SSH server as root before switching user
|
# Start SSH server only if explicitly enabled
|
||||||
echo "Starting SSH server..."
|
if [ "$MC_SSH_ENABLED" = "true" ]; then
|
||||||
/usr/sbin/sshd
|
echo "Starting SSH server..."
|
||||||
|
/usr/sbin/sshd
|
||||||
|
else
|
||||||
|
echo "SSH server disabled (use --ssh flag to enable)"
|
||||||
|
fi
|
||||||
|
|
||||||
# --- END INSERTED BLOCK ---
|
# --- END INSERTED BLOCK ---
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class Session(BaseModel):
|
|||||||
run_command: Optional[str] = None # Command executed on start
|
run_command: Optional[str] = None # Command executed on start
|
||||||
uid: Optional[int] = None # Store UID used
|
uid: Optional[int] = None # Store UID used
|
||||||
gid: Optional[int] = None # Store GID used
|
gid: Optional[int] = None # Store GID used
|
||||||
|
ssh: bool = False # Whether SSH server is enabled
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user