MCPcopy Create free account
hub / github.com/saltstack/salt / key_deploy

Method key_deploy

salt/client/ssh/__init__.py:612–638  ·  view source on GitHub ↗

Deploy the SSH key if the minions don't auth

(self, host, ret)

Source from the content-addressed store, hash-verified

610 return f"{fp_.read().split()[1]} rsa root@master"
611
612 def key_deploy(self, host, ret):
613 """
614 Deploy the SSH key if the minions don't auth
615 """
616 # `or` initially was `and`, but was changed to be able to "deploy
617 # to multiple hosts" in #22661. Why? On each command error, this checks
618 # if a key deploy can be attempted without it being requested.
619 if not isinstance(ret[host], dict) or self.opts.get("ssh_key_deploy"):
620 target = self.targets[host]
621 if target.get("passwd", False) or self.opts["ssh_passwd"]:
622 self._key_deploy_run(host, target, False)
623 return ret, None
624 if "_error" in ret[host] and ret[host]["_error"] == "Permission denied":
625 target = self.targets[host]
626 # permission denied, attempt to auto deploy ssh key
627 print(
628 "Permission denied for host {}, do you want to deploy "
629 "the salt-ssh key? (password required):".format(host)
630 )
631 deploy = input("[Y/n] ")
632 if deploy.startswith(("n", "N")):
633 return ret, None
634 target["passwd"] = getpass.getpass(
635 "Password for {}@{}: ".format(target["user"], host)
636 )
637 return self._key_deploy_run(host, target, True)
638 return ret, None
639
640 def _key_deploy_run(self, host, target, re_run=True):
641 """

Callers 1

runMethod · 0.95

Calls 3

_key_deploy_runMethod · 0.95
formatMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected