diff --git a/tobiko/shell/sh/_connection.py b/tobiko/shell/sh/_connection.py index 317ee197e..90ffc98f3 100644 --- a/tobiko/shell/sh/_connection.py +++ b/tobiko/shell/sh/_connection.py @@ -443,7 +443,7 @@ class SSHShellConnection(ShellConnection): @property def username(self) -> str: - return self.ssh_client.username + return self.ssh_client.setup_connect_parameters()['username'] _hostname: typing.Optional[str] = None @@ -462,8 +462,9 @@ class SSHShellConnection(ShellConnection): return self._sftp def get_environ(self) -> typing.Dict[str, str]: + lines = self.execute('source /etc/profile; env').stdout.splitlines() return dict(_parse_env_line(line) - for line in self.execute('env').stdout().splitlines() + for line in lines if line.strip()) def put_file(self, local_file: str, remote_file: str): diff --git a/tobiko/tests/functional/shell/sh/test_connection.py b/tobiko/tests/functional/shell/sh/test_connection.py index feaecf6d2..552bc9c1d 100644 --- a/tobiko/tests/functional/shell/sh/test_connection.py +++ b/tobiko/tests/functional/shell/sh/test_connection.py @@ -234,7 +234,7 @@ class SSHShellConnectionTest(LocalShellConnectionTest): @property def username(self) -> str: - return self.ssh_client.username + return self.ssh_client.setup_connect_parameters()['username'] class CirrosShellConnectionTest(SSHShellConnectionTest):