-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
No way to have SFTP connections load_host_keys()
via transport_params
#715
Comments
If you're open to accepting a PR, I'd be willing to create a PR based on the example above. |
if 'load_host_keys' in transport_params:
ssh.load_host_keys(transport_params['load_host_keys']) Can't the user do this prior to the smart_open.open call? |
Yes, but notice the first line in my example -- that solution involves accessing
|
I wonder if there's a better way to do this without having smart_open know all these paramiko details. I don't want to handle more transport parameters than absolutely necessary. How about: def ssh_client_init(): # user's code
client = paramiko.client.SSHClient()
# additional ssh config goes here
return client
transport_params = {'ssh_client_init': ssh_client_init}
with smart_open(url, 'rb', transport_params=transport_params) as fin:
... I think it's better to pass a callable instead of the client itself because we can use the callable to create a new client whenever we get disconnected. If there is no callable passed, then we can use the default client settings, e.g. what is currently being done. Yet another way is to expose the underlying client. I'm not opposed to that idea, either. Hiding implementation details is a good thing in general, but here it's getting in the way of the user achieving what they want, so it isn't something we have to strictly stick to. |
Problem description
While currently system host keys are loaded: https://github.com/RaRe-Technologies/smart_open/blob/v5.2.1/smart_open/ssh.py#L91
There's currently no way to
load_host_keys()
for verifying the host. It could be added viatransport_params
at paramiko client instantiation. For example, something like:Steps/code to reproduce the problem
Currently unable to verify host key using a local
known_hosts
file.Versions
Checklist
Before you create the issue, please make sure you have:
The text was updated successfully, but these errors were encountered: