/// <summary> /// List SSH2 keys /// </summary> private void SSH2Identities() { var authKeys = _authKeyProvider.GetAvailableSSH2UserAuthKeys() ?? new SSH2UserAuthKey[0]; var message = new OpenSSHAgentForwardingMessage(OpenSSHAgentForwardingMessageType.SSH2_AGENT_IDENTITIES_ANSWER); message.WriteInt32(authKeys.Length); foreach (var key in authKeys) { byte[] blob = key.GetPublicKeyBlob(); message.WriteAsString(blob); message.WriteUTF8String(key.Comment); } Send(message); }
/// <summary> /// List SSH1 RSA keys /// </summary> private void SSH1Identities() { var authKeys = _authKeyProvider.GetAvailableSSH1UserAuthKeys() ?? new SSH1UserAuthKey[0]; var message = new OpenSSHAgentForwardingMessage(OpenSSHAgentForwardingMessageType.SSH_AGENT_RSA_IDENTITIES_ANSWER); message.WriteInt32(authKeys.Length); foreach (var key in authKeys) { message.WriteInt32(key.PublicModulus.BitCount()); SSH1PacketBuilderMixin.WriteBigInteger(message, key.PublicExponent); SSH1PacketBuilderMixin.WriteBigInteger(message, key.PublicModulus); message.WriteString(key.Comment); } Send(message); }
/// <summary> /// Sends a message. /// </summary> /// <param name="message">a message object</param> private void Send(OpenSSHAgentForwardingMessage message) { _channel.Send(message.GetImage()); }