示例#1
0
        protected override void Negotiate()
        {
            //const string defaultCipherAlgoOrder = "AES256CTR;AES256;AES192CTR;AES192;AES128CTR;AES128;Blowfish;TripleDES";
            //string[] cipherAlgorithmOrderArray = defaultCipherAlgoOrder.Split(new Char[] {';'});
            //string[] hostKeyAlgorithmOrderArray = new string[] { "DSA", "RSA" };

            SSHConnectionParameter con = new SSHConnectionParameter();

            con.Protocol           = _destination.Method;
            con.CheckMACError      = (System.Boolean)true; // PEnv.Options.SSHCheckMAC;
            con.UserName           = _destination.Account;
            con.Password           = _destination.PasswordOrPassphrase;
            con.AuthenticationType = _destination.AuthenticationType;
            con.IdentityFile       = _destination.IdentityFileName;
            con.TerminalWidth      = _destination.InitialWidth;
            con.TerminalHeight     = _destination.InitialHeight;
            con.TerminalName       = _destination.TerminalType;
            con.WindowSize         = _client.ConMain.ProtocolOptions.SSHWindowSize;
            //con.PreferableCipherAlgorithms = LocalSSHUtil.ParseCipherAlgorithm(ConsoleMain.Instance.ProtocolOptions.CipherAlgorithmOrder);
            //con.PreferableHostKeyAlgorithms = ConsoleMain.Instance.ProtocolOptions.HostKeyAlgorithmOrder;
            con.AgentForward = _destination.AgentForward;
            if (_client.ConMain.ProtocolOptions.LogSSHEvents)
            {
                con.EventTracer = new SSHEventTracer(_destination.Destination);
            }
            if (_keycheck != null)
            {
                con.KeyCheck += new HostKeyCheckCallback(this.CheckKey);
            }

            SSHTerminalConnection r   = new SSHTerminalConnection((ISSHLoginParameter)_destination);
            SSHConnection         ssh = SSHConnection.Connect(con, r.ConnectionEventReceiver, _socket);

            if (ssh != null)
            {
                if (_client.ConMain.ProtocolOptions.RetainsPassphrase && _destination.AuthenticationType != AuthenticationType.KeyboardInteractive)
                {
                    _client.ConMain.PassphraseCache.Add(_destination.Destination, _destination.Account, _destination.PasswordOrPassphrase); //Ú‘±¬Œ÷Žž‚̂݃Zƒbƒg
                }
                ////_destination.PasswordOrPassphrase = ""; Ú‘±‚Ì•¡»‚Ì‚½‚ß‚É‚±‚±‚ŏÁ‚³‚¸‚ÉŽc‚µ‚Ä‚¨‚­
                r.AttachTransmissionSide(ssh);
                r.UsingSocks = _socks != null;
                _result      = r;
            }
            else
            {
                throw new IOException("Message.SSHConnector.Cancelled");
            }
        }
示例#2
0
 public void SetOwnerConnection(TerminalConnection con)
 {
     _ownerConnection = con;
 }