You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
server host key lookup fails if a server has multiple keys #138
I'm not entirely sure that multiple keys of the same type per-host should be allowed, but openssh supports it so I'm reporting it in case it should be:
We have two servers in an active / inactive setup. We deploy to the inactive server, and then run a switch task to swap their IPs. This makes the previously inactive server active and vice versa.
The trouble is, we then need two SSH keys for the server address (since it might correspond to one of two physical machines). the ssh command-line client supports this if you list both in ~/.ssh/known_hosts, but paramiko does a lookup via hostname, so it will always return only one of the possible keys.
As a workaround, we're overriding the default rejection policy, since we're using fabric and that doesn't allow us to set a custom policy.
custom_hosts = hostkeys.HostKeys(os.path.join(env.project_path, "deployment", "known_hosts"))
class CustomRejectionPolicy(client.MissingHostKeyPolicy):
def missing_host_key(self, client, hostname, key):
if key is not None:
all_keys = [entry.key for entry in custom_hosts._entries]
if key in all_keys:
return
client._log(DEBUG, 'Rejecting %s host key for %s: %s' %
(key.get_name(), hostname, hexlify(key.get_fingerprint())))
raise SSHException('Server %r not found in known_hosts' % hostname)
client.RejectPolicy = CustomRejectionPolicy
Reacted by strarsis, Jain281088, scholich and Eugene Gubenkov
#737 seems to surface this same issue, with the specific use case being a virtual IP across 2 or more hosts.
Suspecting we may be able to solve this just by making the known_hosts mechanism less naive / more in line with OpenSSH (as noted). Without having the code memorized I'd guess it's just lazy use of scalar-value dict keys where we may instead want to use tuples or similar (or a wholly separate structure and not a straight dict).
Also noting to self: this strikes me as a straight up bug, so if we can solve it in a way that doesn't seem too disruptive, it should go into a bugfix or feature release and does not need to get thrown in with 3.0.
Any update on this issue... Are we fixing the issue to support Cluster or Active/DR server implementation. Its a very basic implementaion now a days and without this feature, we are unable to implement Host Key varification.
Hi, this seems to be open for quite a while already. Is there any progress on this? I would love to be able to have the option to provide multiple host keys for the same host to support failover switches
This will likely get wrapped into the overall key/auth overhaul of #387. Right now the next big piece of work is on a major release that drops Python 2 and old versions of 3.x. I believe #387 is still the priority after that.
No specific timeline, unfortunately. bitprophet has to split his open-source time between paramiko, invoke and fabric, and that time has been reduced lately for various reasons.
Activity
bitprophet commentedon Nov 24, 2014
Very belatedly, this sounds legit to me offhand, and feels related to #166 and #437. Labeling for followup.
bitprophet commentedon May 5, 2016
#737 seems to surface this same issue, with the specific use case being a virtual IP across 2 or more hosts.
Suspecting we may be able to solve this just by making the known_hosts mechanism less naive / more in line with OpenSSH (as noted). Without having the code memorized I'd guess it's just lazy use of scalar-value dict keys where we may instead want to use tuples or similar (or a wholly separate structure and not a straight dict).
bitprophet commentedon May 5, 2016
Also noting to self: this strikes me as a straight up bug, so if we can solve it in a way that doesn't seem too disruptive, it should go into a bugfix or feature release and does not need to get thrown in with 3.0.
Jain281088 commentedon May 3, 2017
Any update on this issue... Are we fixing the issue to support Cluster or Active/DR server implementation. Its a very basic implementaion now a days and without this feature, we are unable to implement Host Key varification.
scholich commentedon Jan 27, 2021
Hi, this seems to be open for quite a while already. Is there any progress on this? I would love to be able to have the option to provide multiple host keys for the same host to support failover switches
bencroft commentedon Aug 29, 2022
Hello there. Is there progress on this issue? It seems that it could be commonly-needed for load-balanced connections as well.
bskinn commentedon Aug 30, 2022
This will likely get wrapped into the overall key/auth overhaul of #387. Right now the next big piece of work is on a major release that drops Python 2 and old versions of 3.x. I believe #387 is still the priority after that.
No specific timeline, unfortunately. bitprophet has to split his open-source time between paramiko, invoke and fabric, and that time has been reduced lately for various reasons.