Repository navigation
Conversation
|
I never circled back on #625, just blatted some thoughts there. This is a good partial solution insofar as it prevents the sanity reload of the file from dying if we're in the "I gave you a new, nonexistent known_hosts file that I expect you to create for me" scenario. It will still IOError if the path is invalid or if permissions don't allow opening for writes. This is largely good - we do not want to mkdir despite that feeling like a nice thing to do, it actually just makes user error harder to spot :) - but as I noted in #625, if we want to act like OpenSSH's client program, the "best" behavior is to warn about those IOErrors and continue operating. If you'd like to update this so it wraps the file open/write in a try/except for IOError, and writes a warning to stderr in the except clause, that'd be aces. Tests would also be awesome. I'll add this or the parent to a release milestone so somebody gets to it sometime though. Thanks! |
also use hostkeys.save() which was same as existing code.
|
I added the IOError warnings. Ref added to #835 also talks about this. |
Quick fix that addresses #625 for the case where known_hosts does not exist.
Note: This does not create the parent directory, not sure the opinions on that, but it likely should, but the concern I would have is that the path to the known_host file could potentially be created outside our control, so it's not guaranteed we're working on ~/.ssh ...
Perhaps a compromise might be to add a test for the directory existing and report that as a clean failure or we just let the open Exception fire.