|
|
|
@ -5,8 +5,8 @@ from typing import Union |
|
|
|
import paramiko |
|
|
|
|
|
|
|
|
|
|
|
def connection_from_config(name: str, ssh_config_root: Path): |
|
|
|
"""Create a connection from a Host entry in the .ssh/config file""" |
|
|
|
def client_from_config(name: str, ssh_config_root: Path): |
|
|
|
"""Create a client from a Host entry in the .ssh/config file""" |
|
|
|
config = paramiko.config.SSHConfig() |
|
|
|
cp = ssh_config_root / "config" |
|
|
|
with open(cp) as file: |
|
|
|
@ -46,9 +46,9 @@ def connection_from_config(name: str, ssh_config_root: Path): |
|
|
|
return client |
|
|
|
|
|
|
|
|
|
|
|
def exec_remote(connection: paramiko.SSHClient, command: Union[str, list]): |
|
|
|
def exec_remote(client: paramiko.SSHClient, command: Union[str, list]): |
|
|
|
"""Function to execute specified command on conection""" |
|
|
|
if not isinstance(command, str): |
|
|
|
command = list2cmdline(command) |
|
|
|
stdin, stdout, stderr = connection.exec_command(command) |
|
|
|
stdin, stdout, stderr = client.exec_command(command) |
|
|
|
return stdout, stderr |