-
Notifications
You must be signed in to change notification settings - Fork 8
Remote: Automatically manage known hosts keys #451
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,9 +93,12 @@ def __init__( | |
| ) | ||
| self._ssh_host = config["ssh_host"] | ||
| self._ssh_username = config["ssh_username"] | ||
| self._ssh_known_hosts = os.path.abspath( | ||
| os.path.expanduser(config["known_hosts"]) | ||
| ) | ||
| if "known_hosts" in config: | ||
| self._ssh_known_hosts = os.path.abspath( | ||
| os.path.expanduser(config["known_hosts"]) | ||
| ) | ||
| else: | ||
| self._ssh_known_hosts = None | ||
| self._ssh_ask_for_password: Union[bool, str] = False | ||
| self._ssh_key = ( | ||
| os.path.abspath(os.path.expanduser(config["ssh_key"])) | ||
|
|
@@ -346,7 +349,10 @@ def _open_ssh_connection(self) -> paramiko.SSHClient: | |
| paramiko.SSHClient: The SSH connection object. | ||
| """ | ||
| ssh = paramiko.SSHClient() | ||
| ssh.load_host_keys(self._ssh_known_hosts) | ||
| if self._ssh_known_hosts is not None: | ||
| ssh.load_host_keys(self._ssh_known_hosts) | ||
| else: | ||
| ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | ||
|
||
| if ( | ||
| self._ssh_key is not None | ||
| and self._ssh_key_passphrase is not None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden known_hosts config handling; avoid empty-string bug and add explicit opt-in for auto-accepting unknown hosts
Proposed fix:
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents