Skip to content

Commit

Permalink
Allow passthrough arguments for SSH connections (#37)
Browse files Browse the repository at this point in the history
This allows users to make more use of complex SSH configuration. The existing interface only allowed for direct connection to a single host. This made basic things like jump hosts inaccessible.

Users can now pass through any keyword arguments accepted by [`fabric.Connection`](https://docs.fabfile.org/en/stable/api/connection.html)
  • Loading branch information
super-cooper authored Jan 19, 2023
1 parent bdf35c6 commit 3512397
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions chi/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@


class Remote(Connection):
def __init__(self, ip=None, server=None, user="cc"):
def __init__(self, ip=None, server=None, user="cc", **kwargs):
if ip is None:
if server is None:
raise ValueError("ip or server must be provided.")
ip = server.ip

if not kwargs.get("connect_kwargs"):
kwargs["connect_kwargs"] = {}
key_filename = context.get("keypair_private_key")
connect_kwargs = {"key_filename": key_filename}
super(Remote, self).__init__(ip, user=user, connect_kwargs=connect_kwargs)
kwargs["connect_kwargs"].setdefault("key_filename", key_filename)
super(Remote, self).__init__(ip, user=user, **kwargs)
# Default policy is to reject unknown hosts - for our use-case,
# printing a warning is probably enough, given the host is almost
# always guaranteed to be unknown.
Expand Down

0 comments on commit 3512397

Please sign in to comment.