Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class RelPath(str):
"keyfile": str,
"timeout": Coerce(int),
"gss_auth": Bool,
"allow_agent": Bool,
**REMOTE_COMMON,
},
"hdfs": {"user": str, **REMOTE_COMMON},
Expand Down
2 changes: 2 additions & 0 deletions dvc/tree/ssh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __init__(self, repo, config):
self.sock = paramiko.ProxyCommand(proxy_command)
else:
self.sock = None
self.allow_agent = config.get("allow_agent", True)

@staticmethod
def ssh_config_filename():
Expand Down Expand Up @@ -143,6 +144,7 @@ def ssh(self, path_info):
password=self.password,
gss_auth=self.gss_auth,
sock=self.sock,
allow_agent=self.allow_agent,
)

@contextmanager
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/remote/ssh/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,31 @@ def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
assert tree.gss_auth == expected_gss_auth


@pytest.mark.parametrize(
"config,expected_allow_agent",
[
({"url": "ssh://example.com"}, True),
({"url": "ssh://not_in_ssh_config.com"}, True),
({"url": "ssh://example.com", "allow_agent": True}, True),
({"url": "ssh://example.com", "allow_agent": False}, False),
],
)
@patch("os.path.exists", return_value=True)
@patch(
f"{builtin_module_name}.open",
new_callable=mock_open,
read_data=mock_ssh_config,
)
def test_ssh_allow_agent(
mock_file, mock_exists, dvc, config, expected_allow_agent
):
tree = SSHTree(dvc, config)

mock_exists.assert_called_with(SSHTree.ssh_config_filename())
mock_file.assert_called_with(SSHTree.ssh_config_filename())
assert tree.allow_agent == expected_allow_agent


def test_hardlink_optimization(dvc, tmp_dir, ssh):
tree = SSHTree(dvc, ssh.config)

Expand Down