addSshKeyToAgent method

Future<void> addSshKeyToAgent(
  1. File sshKey
)

Adds the ssh key to the ssh-agent

Implementation

Future<void> addSshKeyToAgent(File sshKey) async {
  logger.detail('try to add ssh key to ssh-agent');

  final RunResult? result = await processRunner.runCommand(
    hostPlatform.addSshKeyToAgent(filePath: sshKey.path),
    parseResult: (result) => result,
    parseFail: (e, s) {
      throwToolExit(
          'Something went wrong while adding the key to ssh-agent. \nException: $e \nStack: $s');
    },
  );

  if (result?.exitCode != 0) {
    logger.detail('addSshKeyToAgent exitCode: ${result?.exitCode}');
    logger.detail('addSshKeyToAgent stdout: ${result?.stdout}');
    logger.detail('addSshKeyToAgent stderr: ${result?.stderr}');

    throwToolExit('Something went wrong while generating the ssh key.');
  }
}