Altax\Module\Task\Process\Executor::askPassphrase PHP Method

askPassphrase() public method

Ask SSH key passphrase.
public askPassphrase ( $validatingKey ) : string
return string passphrase
    public function askPassphrase($validatingKey)
    {
        $output = $this->runtimeTask->getOutput();
        $command = $this->runtimeTask->getCommand();
        $dialog = $command->getHelperSet()->get('dialog');
        $passphrase = $dialog->askHiddenResponseAndValidate($output, '<info>Enter passphrase for SSH key [<comment>' . $validatingKey . '</comment>]: </info>', function ($answer) use($validatingKey) {
            $key = new \Crypt_RSA();
            $key->setPassword($answer);
            $keyFile = file_get_contents($validatingKey);
            if (!$key->loadKey($keyFile)) {
                throw new \RuntimeException('wrong passphrase.');
            }
            return $answer;
        }, 3, null);
        return $passphrase;
    }