connect

SSH Connection Utilities for GONet Remote Access.

This module defines a decorator for safely managing SSH connections to a remote GONet device. It abstracts away the connection lifecycle, allowing decorated functions to focus solely on their task with an active paramiko.client.SSHClient instance.

Environment

Uses credentials from GONet_Wizard.commands.settings.GONetConfig:

  • GONET_USER

  • GONET_PASSWORD

Functions

  • ssh_connect() : Decorator for establishing an SSH connection before calling a remote operation.

Functions:

GONet_Wizard.commands.connect.ssh_connect(func)[source]

Decorator for establishing an SSH connection before calling a remote operation.

This decorator wraps a function that requires a live SSH connection. It manages: - Setting up the SSH client - Connecting to the given GONet device IP - Passing the connected SSH client to the decorated function - Automatically closing the connection afterward

Parameters:

func (Callable[[paramiko.client.SSHClient, Any], Any]) – A function that expects a connected SSH client as its first argument.

Returns:

A new function that takes the GONet device IP address and any additional arguments. The SSH connection is established using the environment-configured credentials.

Return type:

Callable[[str, Any], Any]

Raises:

Exception – If the SSH connection fails for any reason (auth, network, etc.), the exception is propagated.

Example

>>> @ssh_connect
... def list_home(ssh):
...     _, stdout, _ = ssh.exec_command("ls ~")
...     print(stdout.read().decode())
>>> list_home("192.168.1.101")