static ISshKey GetSshKey(Func <Stream> getPrivateKeyStream, Func <Stream> getPublicKeyStream, string fallbackComment, KeyFormatter.GetPassphraseCallback getPassphrase) { ISshKey key; using (var privateKeyStream = getPrivateKeyStream()) key = privateKeyStream.ReadSshKey(getPassphrase); if (string.IsNullOrWhiteSpace(key.Comment) && getPublicKeyStream != null) { using (var stream = getPublicKeyStream()) key.Comment = KeyFormatter.GetComment(stream.ReadAllLines(Encoding.UTF8)); } if (string.IsNullOrWhiteSpace(key.Comment)) { key.Comment = fallbackComment; } return(key); }