Skip to content

Commit

Permalink
Backport PR #22691 on branch 6.x (PR: Provide username, host and port…
Browse files Browse the repository at this point in the history
… from hostname info in ssh tunnels) (#22749)
  • Loading branch information
meeseeksmachine authored Oct 28, 2024
1 parent 20fd3b8 commit 25d5af8
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions spyder/plugins/ipythonconsole/utils/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def tunnel_to_kernel(
)
elif sshkey is not None:
self.__tunnel_handler = KernelClientTunneler.new_connection(
tunnel=hostname,
password=password,
client_keys=[sshkey],
**self._split_shh_address(hostname),
)
else:
self.__tunnel_handler = KernelClientTunneler.new_connection(
tunnel=hostname,
password=password,
**self._split_shh_address(hostname),
)

(
Expand All @@ -129,3 +129,14 @@ def tunnel_to_kernel(
)
)
self.ip = "127.0.0.1" # Tunneled to localhost

@staticmethod
def _split_shh_address(address):
"""Split ssh address into host and port."""
user_host, _, port = address.partition(':')
user, _, host = user_host.rpartition('@')
return {
'username': user if user else None,
'host': host if host else None,
'port': int(port) if port else None
}

0 comments on commit 25d5af8

Please sign in to comment.