Skip to content

Commit

Permalink
Merge pull request spyder-ide#22691 from hlouzada/fix-hostname-tunnels
Browse files Browse the repository at this point in the history
PR: Provide username, host and port from hostname info in ssh tunnels
  • Loading branch information
ccordoba12 authored Oct 28, 2024
2 parents 2b7208b + 789ffc9 commit 85df89f
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 85df89f

Please sign in to comment.