Python Twisted: twisted conch filetransfer verifyHostKey -


I'm playing with sftp example from here:

I use it here to connect I am doing Therefore, I can use a string key or key instead of a password in ~ / .shh. Now I want to distribute hosts or fingerprints from the host so that users can not verify the hostname

  def sftp (user, host, port, key, hostkey): options = ClientOptions ['key'] = keys. Key.frame string (key.strip ()). Key object option ['host'] = host option ['port'] = port conn = SFTPConnection () conn._sftp = deferred () Auth = SSHUserAuthClient (user, option, conn) (host, port, options, verifyHostKey, auth ) To connect conn._sftp   

I tried to verify some arguments, as you can do that the ultimate fingerprint is not used in the A valid value is not found for.

  def verify host (Transport, Host, Pub, Fingerprint): "" "Verify Host Key ....   

Any ideas how Can I be prompted to verify the hostname of a host without having to write hostname ~ / .shh / known_hosts?

OK, I wrote a function based on the answer of Jean-Paul Calderon I'm fairly naive but this work is good. E-goal comes with a known host file I wanted to eliminate all the keys in memory only.

  def verify hostkey (transport, host, shower, fingerprint): key type, key = transport. ['Hostkey']. Partition (if "key.fromString (hostkey) key.fingerprint () == Fingerprint: The return is successful (true) Other: Increase BadKeyError    

I tried to give some argument to confirm

Security Are you saying you Styapanhostki try to call? It seems that the user is not helping you avoid motivating for unknown host keys. Instead, you want to pass a different function from connect for that parameter, provided by verifyHostKey function provided by twisted.conch.client.default Instead of using it, use one like this:

  twisted.internet to   

Or, if you want to apply your own investigation , Not just accept a host key, define the function in which it is checked. Return a deferred, and if the investigation succeeds, then the fire which is defended with truth, if the investigation fails, then set it to a false fire.

Comments