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

default host key policy to RejectPolicy #2280

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions fabric/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from invoke import Context
from invoke.exceptions import ThreadException
from paramiko.agent import AgentRequestHandler
from paramiko.client import SSHClient, AutoAddPolicy
from paramiko.client import SSHClient, RejectPolicy
from paramiko.config import SSHConfig
from paramiko.proxy import ProxyCommand

Expand Down Expand Up @@ -455,7 +455,7 @@ def __init__(

#: The `paramiko.client.SSHClient` instance this connection wraps.
client = SSHClient()
client.set_missing_host_key_policy(AutoAddPolicy())
client.set_missing_host_key_policy(RejectPolicy())
self.client = client

#: A convenience handle onto the return value of
Expand Down
6 changes: 3 additions & 3 deletions tests/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time

from unittest.mock import patch, Mock, call, ANY
from paramiko.client import SSHClient, AutoAddPolicy
from paramiko.client import SSHClient, RejectPolicy
from paramiko import SSHConfig
import pytest # for mark, internal raises
from pytest import skip, param
Expand Down Expand Up @@ -65,7 +65,7 @@ class known_hosts_behavior:
def defaults_to_auto_add(self):
# TODO: change Paramiko API so this isn't a private access
# TODO: maybe just merge with the __init__ test that is similar
assert isinstance(Connection("host").client._policy, AutoAddPolicy)
assert isinstance(Connection("host").client._policy, RejectPolicy)

class init:
"__init__"
Expand Down Expand Up @@ -245,7 +245,7 @@ def instantiates_empty_SSHClient(self, Client):
Connection("host")
Client.assert_called_once_with()

@patch("fabric.connection.AutoAddPolicy")
@patch("fabric.connection.RejectPolicy")
def sets_missing_host_key_policy(self, Policy, client):
# TODO: should make the policy configurable early on
sentinel = Mock()
Expand Down