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

fortinet _preferred_kex settings interfering with other devices #3463

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
27 changes: 17 additions & 10 deletions netmiko/fortinet/fortinet_ssh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import paramiko
import re
from typing import Optional
from typing import Optional, Any

from netmiko.no_config import NoConfig
from netmiko.no_enable import NoEnable
Expand All @@ -10,15 +10,22 @@
class FortinetSSH(NoConfig, NoEnable, CiscoSSHConnection):
prompt_pattern = r"[#$]"

def _modify_connection_params(self) -> None:
"""Modify connection parameters prior to SSH connection."""
paramiko_transport = getattr(paramiko, "Transport")
paramiko_transport._preferred_kex = (
"diffie-hellman-group14-sha1",
"diffie-hellman-group-exchange-sha1",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group1-sha1",
)
def __init__(self, *args: Any, **kwargs: Any) -> None:
disabled_algorithms = kwargs.get("disabled_algorithms")
if disabled_algorithms is None:
# We only want these and disable the rest
_preferred_kex = {
"diffie-hellman-group14-sha1",
"diffie-hellman-group-exchange-sha1",
"diffie-hellman-group-exchange-sha256",
"diffie-hellman-group1-sha1",
}
paramiko_transport = getattr(paramiko, "Transport")
kwargs["disabled_algorithms"] = {
"kex": list(set(paramiko_transport._preferred_kex) - _preferred_kex)
}

super().__init__(*args, **kwargs)

def _try_session_preparation(self, force_data: bool = False) -> None:
super()._try_session_preparation(force_data=force_data)
Expand Down