Inheritance: ISSHProtocolEventLogger
Ejemplo n.º 1
0
        protected override void Negotiate()
        {
            ITerminalParameter term = (ITerminalParameter)_destination.GetAdapter(typeof(ITerminalParameter));
            ITCPParameter tcp = (ITCPParameter)_destination.GetAdapter(typeof(ITCPParameter));

            SSHTerminalConnection terminalConnection = new SSHTerminalConnection(_destination);

            SSHConnectionParameter con =
                new SSHConnectionParameter(
                    tcp.Destination,
                    tcp.Port,
                    _destination.Method,
                    _destination.AuthenticationType,
                    _destination.Account,
                    _destination.PasswordOrPassphrase);
            #if DEBUG
            // con.EventTracer = new SSHDebugTracer();
            #endif
            con.Protocol = _destination.Method;
            con.CheckMACError = PEnv.Options.SSHCheckMAC;
            con.UserName = _destination.Account;
            con.Password = _destination.PasswordOrPassphrase;
            con.AuthenticationType = _destination.AuthenticationType;
            con.IdentityFile = _destination.IdentityFileName;
            con.TerminalWidth = term.InitialWidth;
            con.TerminalHeight = term.InitialHeight;
            con.TerminalName = term.TerminalType;
            con.WindowSize = PEnv.Options.SSHWindowSize;
            con.PreferableCipherAlgorithms =
                LocalSSHUtil.AppendMissingCipherAlgorithm(
                    LocalSSHUtil.ParseCipherAlgorithm(PEnv.Options.CipherAlgorithmOrder));
            con.PreferableHostKeyAlgorithms =
                LocalSSHUtil.AppendMissingPublicKeyAlgorithm(
                    LocalSSHUtil.ParsePublicKeyAlgorithm(PEnv.Options.HostKeyAlgorithmOrder));
            con.AgentForwardingAuthKeyProvider = _destination.AgentForwardingAuthKeyProvider;
            con.X11ForwardingParams = _destination.X11Forwarding;
            if (_keycheck != null) {
                con.VerifySSHHostKey = (info) => {
                    return _keycheck.Vefiry(info);
                };
            }
            con.KeyboardInteractiveAuthenticationHandlerCreator =
                sshconn => terminalConnection.GetKeyboardInteractiveAuthenticationHandler();

            ISSHProtocolEventLogger protocolEventLogger;
            if (ProtocolsPlugin.Instance.ProtocolOptions.LogSSHEvents) {
                protocolEventLogger = new SSHEventTracer(tcp.Destination);
            }
            else {
                protocolEventLogger = null;
            }

            var connection = SSHConnection.Connect(_socket, con,
                                sshconn => terminalConnection.ConnectionEventReceiver,
                                sshconn => protocolEventLogger);
            if (PEnv.Options.RetainsPassphrase && _destination.AuthenticationType != AuthenticationType.KeyboardInteractive) {
                ProtocolsPlugin.Instance.PassphraseCache.Add(tcp.Destination, _destination.Account, _destination.PasswordOrPassphrase); //接続成功時のみセット
            }
            //_destination.PasswordOrPassphrase = ""; 接続の複製のためにここで消さずに残しておく
            terminalConnection.AttachTransmissionSide(connection, connection.AuthenticationStatus);
            _result = terminalConnection;
        }
Ejemplo n.º 2
0
        protected override void Negotiate()
        {
            ITerminalParameter term = (ITerminalParameter)_destination.GetAdapter(typeof(ITerminalParameter));
            ITCPParameter      tcp  = (ITCPParameter)_destination.GetAdapter(typeof(ITCPParameter));

            SSHTerminalConnection terminalConnection = new SSHTerminalConnection(_destination);

            SSHConnectionParameter con =
                new SSHConnectionParameter(
                    tcp.Destination,
                    tcp.Port,
                    _destination.Method,
                    _destination.AuthenticationType,
                    _destination.Account,
                    _destination.PasswordOrPassphrase);

#if DEBUG
            // con.EventTracer = new SSHDebugTracer();
#endif
            con.Protocol                       = _destination.Method;
            con.CheckMACError                  = PEnv.Options.SSHCheckMAC;
            con.UserName                       = _destination.Account;
            con.Password                       = _destination.PasswordOrPassphrase;
            con.AuthenticationType             = _destination.AuthenticationType;
            con.IdentityFile                   = _destination.IdentityFileName;
            con.TerminalWidth                  = term.InitialWidth;
            con.TerminalHeight                 = term.InitialHeight;
            con.TerminalName                   = term.TerminalType;
            con.WindowSize                     = PEnv.Options.SSHWindowSize;
            con.PreferableCipherAlgorithms     = LocalSSHUtil.ParseCipherAlgorithm(PEnv.Options.CipherAlgorithmOrder);
            con.PreferableHostKeyAlgorithms    = LocalSSHUtil.ParsePublicKeyAlgorithm(PEnv.Options.HostKeyAlgorithmOrder);
            con.AgentForwardingAuthKeyProvider = _destination.AgentForwardingAuthKeyProvider;
            if (_keycheck != null)
            {
                con.VerifySSHHostKey = (info) => {
                    return(_keycheck.Vefiry(info));
                };
            }
            con.KeyboardInteractiveAuthenticationHandlerCreator =
                sshconn => terminalConnection.GetKeyboardInteractiveAuthenticationHandler();

            ISSHProtocolEventLogger protocolEventLogger;
            if (ProtocolsPlugin.Instance.ProtocolOptions.LogSSHEvents)
            {
                protocolEventLogger = new SSHEventTracer(tcp.Destination);
            }
            else
            {
                protocolEventLogger = null;
            }

            var connection = SSHConnection.Connect(_socket, con,
                                                   sshconn => terminalConnection.ConnectionEventReceiver,
                                                   sshconn => protocolEventLogger);
            if (PEnv.Options.RetainsPassphrase && _destination.AuthenticationType != AuthenticationType.KeyboardInteractive)
            {
                ProtocolsPlugin.Instance.PassphraseCache.Add(tcp.Destination, _destination.Account, _destination.PasswordOrPassphrase); //接続成功時のみセット
            }
            //_destination.PasswordOrPassphrase = ""; 接続の複製のためにここで消さずに残しておく
            terminalConnection.AttachTransmissionSide(connection, connection.AuthenticationStatus);
            _result = terminalConnection;
        }
Ejemplo n.º 3
0
        protected override void Negotiate()
        {
            ITerminalParameter term = (ITerminalParameter)_destination.GetAdapter(typeof(ITerminalParameter));
            ITCPParameter      tcp  = (ITCPParameter)_destination.GetAdapter(typeof(ITCPParameter));

            SSHTerminalConnection terminalConnection = new SSHTerminalConnection(_destination);

            SSHConnectionParameter con =
                new SSHConnectionParameter(
                    tcp.Destination,
                    tcp.Port,
                    _destination.Method,
                    _destination.AuthenticationType,
                    _destination.Account,
                    _destination.PasswordOrPassphrase);

#if DEBUG
            // con.EventTracer = new SSHDebugTracer();
#endif
            con.Protocol                   = _destination.Method;
            con.CheckMACError              = PEnv.Options.SSHCheckMAC;
            con.UserName                   = _destination.Account;
            con.Password                   = _destination.PasswordOrPassphrase;
            con.AuthenticationType         = _destination.AuthenticationType;
            con.IdentityFile               = _destination.IdentityFileName;
            con.TerminalWidth              = term.InitialWidth;
            con.TerminalHeight             = term.InitialHeight;
            con.TerminalName               = term.TerminalType;
            con.WindowSize                 = PEnv.Options.SSHWindowSize;
            con.Timeouts.ResponseTimeout   = PEnv.Options.SSHResponseTimeout;
            con.PreferableCipherAlgorithms =
                LocalSSHUtil.AppendMissingCipherAlgorithm(
                    LocalSSHUtil.ParseCipherAlgorithm(PEnv.Options.CipherAlgorithmOrder));
            con.PreferableHostKeyAlgorithms =
                LocalSSHUtil.AppendMissingPublicKeyAlgorithm(
                    LocalSSHUtil.ParsePublicKeyAlgorithm(PEnv.Options.HostKeyAlgorithmOrder));
            con.AgentForwardingAuthKeyProvider = _destination.AgentForwardingAuthKeyProvider;
            con.X11ForwardingParams            = _destination.X11Forwarding;
            if (_keycheck != null)
            {
                con.VerifySSHHostKey = (info) => {
                    return(_keycheck.Vefiry(info));
                };
            }
            con.KeyboardInteractiveAuthenticationHandlerCreator =
                sshconn => terminalConnection.GetKeyboardInteractiveAuthenticationHandler();

            ISSHProtocolEventLogger protocolEventLogger;
            if (ProtocolsPlugin.Instance.ProtocolOptions.LogSSHEvents)
            {
                protocolEventLogger = new SSHEventTracer(tcp.Destination);
            }
            else
            {
                protocolEventLogger = null;
            }

            var connection = SSHConnection.Connect(_socket, con,
                                                   sshconn => terminalConnection.ConnectionEventReceiver,
                                                   sshconn => protocolEventLogger);

            // Note: password must not be cleared here. it will be required when duplicating connection later.

            // The login settings was accepted.
            // No need to ask a password on the new attempt to login from the shortcut functionality.
            _destination.LetUserInputPassword = false;

            terminalConnection.AttachTransmissionSide(connection, connection.AuthenticationStatus);
            _result = terminalConnection;
        }