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
10 changes: 5 additions & 5 deletions dvc/fs/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ def _prepare_credentials(self, **config):
or self.DEFAULT_PORT
)

if config.get("ask_password") and config.get("password") is None:
config["password"] = ask_password(
login_info["host"], login_info["username"], login_info["port"]
)

login_info["password"] = config.get("password")
login_info["passphrase"] = config.get("password")

Expand Down Expand Up @@ -101,11 +106,6 @@ def _prepare_credentials(self, **config):
login_info["agent_forwarding"] = config.get("agent_forwarding", True)
login_info["proxy_command"] = user_ssh_config.get("ProxyCommand")

if config.get("ask_password") and login_info["password"] is None:
login_info["password"] = ask_password(
login_info["host"], login_info["username"], login_info["port"]
)

# We are going to automatically add stuff to known_hosts
# something like paramiko's AutoAddPolicy()
login_info["known_hosts"] = None
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/fs/test_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def test_init():
assert fs.fs_args["password"] == fs.fs_args["passphrase"] == "xxx"


def test_ssh_ask_password(mocker):
mocker.patch("dvc.fs.ssh.ask_password", return_value="fish")
fs = SSHFileSystem(user="test", host="2.2.2.2", ask_password=True)
assert fs.fs_args["password"] == fs.fs_args["passphrase"] == "fish"


mock_ssh_config = """
Host example.com
User ubuntu
Expand Down