Skip to content

SshExecutionEnvironmentConfig

Base classes

Name Children Inherits
BaseExecutionEnvironmentConfig
exxec_config.configs
Base execution environment configuration.

â‹” Inheritance diagram

graph TD
  1566868366["configs.SshExecutionEnvironmentConfig"]
  2844377061["configs.BaseExecutionEnvironmentConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2844377061 --> 1566868366
  330168112 --> 2844377061
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseExecutionEnvironmentConfig

SSH execution environment configuration.

Executes code on a remote machine via SSH connection.

Source code in src/exxec_config/configs.py
class SshExecutionEnvironmentConfig(BaseExecutionEnvironmentConfig):
    """SSH execution environment configuration.

    Executes code on a remote machine via SSH connection.
    """

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "SSH Execution Environment"})

    type: Literal["ssh"] = Field("ssh", init=False)

    host: str = Field(title="Host", examples=["192.168.1.100", "example.com"])
    """Remote host to connect to."""

    username: str = Field(title="Username", examples=["ubuntu", "root"])
    """SSH username."""

    password: SecretStr | None = Field(default=None, title="Password")
    """SSH password (if not using key auth)."""

    private_key_path: str | None = Field(
        default=None,
        title="Private Key Path",
        examples=["~/.ssh/id_rsa", "/path/to/key"],
    )
    """Path to SSH private key file."""

    port: int = Field(default=22, ge=1, le=65535, title="SSH Port")
    """SSH port."""

    language: Language = Field(
        default="python",
        title="Programming Language",
        examples=["python", "javascript", "typescript"],
    )
    """Programming language to use."""

    sandbox_timeout: float = Field(
        default=300.0,
        gt=0.0,
        title="Connection Timeout",
        examples=[300.0, 600.0, 3600.0],
    )
    """SSH connection timeout in seconds."""

    def get_provider(
        self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
    ) -> SshExecutionEnvironment:
        """Create SSH execution environment instance."""
        from exxec.ssh_provider import SshExecutionEnvironment

        password_str = self.password.get_secret_value() if self.password else None
        return SshExecutionEnvironment(
            host=self.host,
            username=self.username,
            lifespan_handler=lifespan_handler,
            dependencies=self.dependencies,
            password=password_str,
            private_key_path=self.private_key_path,
            port=self.port,
            timeout=self.sandbox_timeout,
            default_command_timeout=self.default_command_timeout,
            language=self.language,
            cwd=self.cwd,
            env_vars=self.env_vars,
            inherit_env=self.inherit_env,
        )

host class-attribute instance-attribute

host: str = Field(title='Host', examples=['192.168.1.100', 'example.com'])

Remote host to connect to.

language class-attribute instance-attribute

language: Language = Field(
    default="python", title="Programming Language", examples=["python", "javascript", "typescript"]
)

Programming language to use.

password class-attribute instance-attribute

password: SecretStr | None = Field(default=None, title='Password')

SSH password (if not using key auth).

port class-attribute instance-attribute

port: int = Field(default=22, ge=1, le=65535, title='SSH Port')

SSH port.

private_key_path class-attribute instance-attribute

private_key_path: str | None = Field(
    default=None, title="Private Key Path", examples=["~/.ssh/id_rsa", "/path/to/key"]
)

Path to SSH private key file.

sandbox_timeout class-attribute instance-attribute

sandbox_timeout: float = Field(
    default=300.0, gt=0.0, title="Connection Timeout", examples=[300.0, 600.0, 3600.0]
)

SSH connection timeout in seconds.

username class-attribute instance-attribute

username: str = Field(title='Username', examples=['ubuntu', 'root'])

SSH username.

get_provider

get_provider(
    lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None,
) -> SshExecutionEnvironment

Create SSH execution environment instance.

Source code in src/exxec_config/configs.py
def get_provider(
    self, lifespan_handler: AbstractAsyncContextManager[ServerInfo] | None = None
) -> SshExecutionEnvironment:
    """Create SSH execution environment instance."""
    from exxec.ssh_provider import SshExecutionEnvironment

    password_str = self.password.get_secret_value() if self.password else None
    return SshExecutionEnvironment(
        host=self.host,
        username=self.username,
        lifespan_handler=lifespan_handler,
        dependencies=self.dependencies,
        password=password_str,
        private_key_path=self.private_key_path,
        port=self.port,
        timeout=self.sandbox_timeout,
        default_command_timeout=self.default_command_timeout,
        language=self.language,
        cwd=self.cwd,
        env_vars=self.env_vars,
        inherit_env=self.inherit_env,
    )

:fa-brands-github: Show source on GitHub