If the user is running via SSH, their Keychain must be unlocked first.
548324
def unlock_keychain(username):
    

    if 'SSH_TTY' not in os.environ:
        return

    # Don't unlock if we've already seen this user.
    if username in _unlocked:
        return

    _unlocked.add(username)

    if sys.platform == 'darwin':
        sys.stderr.write("You are running under SSH. Please unlock your local OS X KeyChain:\n")
        subprocess.call(['security', 'unlock-keychain'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
231423
protected function verifyInternalKey()
    {
        // if we are running in stateless mode, there's no need for an IPC key.
        if ($this->isStateless()) {
            $this->setInternalKey('');
              return;
        }

        if (trim($this->getInternalKey()) == '') {
            if (session_id() != '') { /*if programmer already started session, use it*/
                $this->setInternalKey("/tmp/" . session_id());
            } else {
                $this->setInternalKey("/tmp/". $this->generate_name());
            }
        }
    }
1335076
def ssh(
            self, machine, *,
            username=None, command=None, boot_only=False, discovered=False,
            wait=300):
        """"""
        start_time = time.monotonic()
        with utils.Spinner() as context:
            context.msg = colorized(
                "{autoblue}Determining{/autoblue} best IP for %s" % (
                    machine.hostname))
            ip_addresses = self.get_ip_addresses(
                machine, boot_only=boot_only, discovered=discovered)
            if len(ip_addresses) > 0:
                pingable_ips = self._async_get_sshable_ips(ip_addresses)
                while (len(pingable_ips) == 0 and
                        (time.monotonic() - start_time) < wait):
                    time.sleep(5)
                    pingable_ips = self._async_get_sshable_ips(ip_addresses)
                if len(pingable_ips) == 0:
                    raise CommandError(
                        "No IP addresses on %s can be reached." % (
                            machine.hostname))
                else:
                    ip = pingable_ips[0]
            else:
                raise CommandError(
                    "%s has no IP addresses." % machine.hostname)

            if username is None:
                context.msg = colorized(
                    "{autoblue}Determining{/autoblue} SSH username on %s" % (
                        machine.hostname))
                username = self._determine_username(ip)
                while (username is None and
                        (time.monotonic() - start_time) < wait):
                    username = self._determine_username(ip)
                if username is None:
                    raise CommandError(
                        "Failed to determine the username for SSH.")

            conn_str = "%s@%s" % (username, ip)
            args = [
                "ssh",
                "-o", "UserKnownHostsFile=/dev/null",
                "-o", "StrictHostKeyChecking=no",
                conn_str
            ]

            context.msg = colorized(
                "{automagenta}Waiting{/automagenta} for SSH on %s" % (
                    machine.hostname))
            check_args = args + ["echo"]
            connectable = self._check_ssh(*check_args)
            while not connectable and (time.monotonic() - start_time) < wait:
                time.sleep(5)
                connectable = self._check_ssh(*check_args)
            if not connectable:
                raise CommandError(
                    "SSH never started on %s using IP %s." % (
                        machine.hostname, ip))

        if command is not None:
            args.append(command)
        ssh = subprocess.Popen(
            args, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)
        ssh.wait()
        return ssh.returncode
913338
public void onUnknownHost(String host, SshPublicKey pk) {
		try {
			System.out.println("The host " + host
					+ " is currently unknown to the system");
			System.out.println("The MD5 host key " + "(" + pk.getAlgorithm()
					+ ") fingerprint is: " + pk.getFingerprint());
			System.out.println("The SHA1 host key "
					+ "("
					+ pk.getAlgorithm()
					+ ") fingerprint is: "
					+ SshKeyFingerprint.getFingerprint(pk.getEncoded(),
							SshKeyFingerprint.SHA1_FINGERPRINT));
			try {
				System.out.println("The SHA256 host key "
						+ "("
						+ pk.getAlgorithm()
						+ ") fingerprint is: "
						+ SshKeyFingerprint.getFingerprint(pk.getEncoded(),
								SshKeyFingerprint.SHA256_FINGERPRINT));
			} catch (Exception ex) {
			}

			getResponse(host, pk);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
882043
def key_deploy(self, host, ret):
        '''
        
        '''
        if not isinstance(ret[host], dict) or self.opts.get('ssh_key_deploy'):
            target = self.targets[host]
            if target.get('passwd', False) or self.opts['ssh_passwd']:
                self._key_deploy_run(host, target, False)
            return ret
        if ret[host].get('stderr', '').count('Permission denied'):
            target = self.targets[host]
            # permission denied, attempt to auto deploy ssh key
            print(('Permission denied for host {0}, do you want to deploy '
                   'the salt-ssh key? (password required):').format(host))
            deploy = input('[Y/n] ')
            if deploy.startswith(('n', 'N')):
                return ret
            target['passwd'] = getpass.getpass(
                    'Password for {0}@{1}: '.format(target['user'], host)
                )
            return self._key_deploy_run(host, target, True)
        return ret
118606
def unlock(user):
    '''
    
    '''

    cmd = 'chuser account_locked=false {0} | ' \
          'chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s {0}'.format(user)
    ret = __salt__['cmd.run_all'](cmd, output_loglevel='trace', python_shell=True)

    return ret
1288357
protected function checkForSSHKeysOrCreate()
    {
        if (File::exists($_SERVER['HOME'] . self::SSH_ID_RSA_PRIV)) {
            $this->info('SSH keys found on your system (~' . self::SSH_ID_RSA_PRIV .')...');
        } else {
            $this->info('No SSH keys found on your system (~' . self::SSH_ID_RSA_PRIV .')!');
            $this->createSSHKeys();
        }
    }
541216
def secure(new_user=env.user):
    
    run("apt-get update -q")
    run("apt-get upgrade -y -q")
    run("adduser --gecos '' %s" % new_user)
    run("usermod -G sudo %s" % new_user)
    run("sed -i 's:RootLogin yes:RootLogin no:' /etc/ssh/sshd_config")
    run("service ssh restart")
    print(green("Security steps completed. Log in to the server as '%s' from "
                "now on." % new_user, bold=True))
820958
def unlock(path, body, initheader = nil)
      request(Unlock.new(path, initheader), body)
    end
949086
def sign(self, blob, identity):
        """"""
        conn = self.conn_factory()
        return conn.sign_ssh_challenge(blob=blob, identity=identity)
874878
function fingerprint(key) {
    assert.string(key, 'ssh_key');

    var k = sshpk.parseKey(key, 'ssh');
    return (k.fingerprint('md5').toString('hex'));
  }
712571
async def add_ssh_key(self, user, key):
        
        key_facade = client.KeyManagerFacade.from_connection(self.connection())
        return await key_facade.AddKeys([key], user)
1143087
def authenticate
      begin
        @backend.transaction(true){
          raise NotInitializedError.new(@backend.path.path) unless @backend[:user] && @backend[:system] && @backend[:system][:created]
          check_salt!
        }
      rescue OpenSSL::Cipher::CipherError
        raise WrongMasterPasswordError
      end
    end
116216
public void onHostKeyMismatch(String host, SshPublicKey pk,
			SshPublicKey actual) {
		try {
			System.out.println("The host key supplied by " + host + "("
					+ pk.getAlgorithm() + ")" + " is: "
					+ actual.getFingerprint());
			System.out.println("The current allowed key for " + host + " is: "
					+ pk.getFingerprint());
			getResponse(host, actual);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
1247321
def ssh(cmd=''):
    '''
    
    '''
    with settings(warn_only=True):
        local('ssh -A -o StrictHostKeyChecking=no -i "%s" %s@%s "%s"' % (
            env.key_filename, env.user, env.host, cmd))
1126676
def login_user_block(username, ssh_keys, create_password=True):
    
    block = {
        'create_password': 'yes' if create_password is True else 'no',
        'ssh_keys': {
            'ssh_key': ssh_keys
        }
    }

    if username:
        block['username'] = username

    return block
509635
def _check_ssh(self, *args):
        """"""
        ssh = subprocess.Popen(
            args,
            stdin=subprocess.DEVNULL,
            stdout=subprocess.DEVNULL,
            stderr=subprocess.DEVNULL)
        ssh.wait()
        return ssh.returncode == 0