Skip to content

Windows machines throwing errors if C:\Users\<USER>\.ssh\knownhosts file is missing #74

@MadsHangaard

Description

@MadsHangaard

Is there an existing issue for this?

  • I have searched the existing issues and added correct labels.

Description

Current Behavior

Using the 1.2.6 develop branch without an existing knownhosts file on Windows results in sftpretty throwing an error.

Expected Behavior

No errors should be thrown when known_hosts file is missing, since cnopts.hostkeys = None is set in client/ayon-sitesync/providers/sftp.py

Steps To Reproduce:

Run the current 1.2.6 develop branch on Windows without a knownhosts file: %USERPROFILE%\.ssh\known_hosts.

Additional context:

Version

Server: 1.13.8
Core: 1.7.2
Launcher: 1.4.3
Ayon-SiteSync: 1.2.6 (current develop branch)

What platform were you running when you found the bug?

Windows

You can also provide any additional information relevant to the issue.

The bug is a result of moving from pysftp to sftpretty and the behavior around ignoring missing knownhosts changing slightly.

I will provide a PR for this.

Relevant log output:

*** WRN: >>> { SiteSyncThread }: [  Unhandled except. in sync loop, stopping server  ] 
==============================
No file or host key found in [ C:/Users/MadsHangaard/.ssh/known_hosts ]. You will need to explicitly load host keys (cnopts.hostkeys.load(filename)) or disable host key verification (CnOpts(knownhosts=None)).
==============================
Traceback (most recent call last):
  File "C:\Users\MadsHangaard\AppData\Local\Ynput\AYON\dependency_packages\ayon_2601221618_windows.zip\runtime\sftpretty\__init__.py", line 106, in __init__
    self.hostkeys.load(Path(knownhosts).resolve().as_posix())
  File "C:\Users\MadsHangaard\AppData\Local\Ynput\AYON\dependency_packages\ayon_2601221618_windows.zip\runtime\paramiko\hostkeys.py", line 89, in load
    with open(filename, "r") as f:
FileNotFoundERROR: [ Errno 2 ] No such file or directory: 'C:/Users/MadsHangaard/.ssh/known_hosts'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\sitesync.py", line 378, in sync_loop
    await self._sync_project(project_name)
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\sitesync.py", line 498, in _sync_project
    local_site, remote_site = self._working_sites(
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\sitesync.py", line 468, in _working_sites
    _site_is_working(
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\sitesync.py", line 219, in _site_is_working
    return handler.is_active()
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\providers\sftp.py", line 75, in is_active
    return self.presets.get("enabled") and self.conn is not None
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\providers\sftp.py", line 65, in conn
    self._conn = self._get_conn()
  File "C:\Users\MadsHangaard\dev\ayon-sitesync\client\ayon_sitesync\providers\sftp.py", line 308, in _get_conn
    cnopts = sftpretty.CnOpts() # knownhosts=None
  File "C:\Users\MadsHangaard\AppData\Local\Ynput\AYON\dependency_packages\ayon_2601221618_windows.zip\runtime\sftpretty\__init__.py", line 109, in __init__
    raise UserWarning(
UserWarning: No file or host key found in [ C:/Users/MadsHangaard/.ssh/known_hosts ]. You will need to explicitly load host keys (cnopts.hostkeys.load(filename)) or disable host key verification (CnOpts(knownhosts=None)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions