Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Provide username, host and port from hostname info in ssh tunnels #22691

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 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:
else:
self.__tunnel_handler = KernelClientTunneler.new_connection(
tunnel=hostname,
password=password,
**self._split_shh_address(hostname),
)

(
Expand All @@ -129,3 +129,12 @@ 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}
Loading