public override ConnectionTag Reproduce() { SSHTerminalParam sshp = (SSHTerminalParam)_param.Clone(); if(GEnv.Options.DefaultLogType!=LogType.None) { sshp.LogType = GEnv.Options.DefaultLogType; sshp.LogPath = GUtil.CreateLogFileName(sshp.ShortDescription); } else sshp.LogType = LogType.None; if(sshp.Method==ConnectionMethod.SSH2 && !this.IsClosed) { //SSH2�̂Ƃ��̓R�l�N�V��������L���ă}���`�`���l����g�p System.Drawing.Size sz = GEnv.Frame.TerminalSizeForNextConnection; SSHTerminalConnection newcon = new SSHTerminalConnection(sshp, sz.Width, sz.Height); newcon.FixConnection(_connection); newcon.OpenShell(); newcon.SetServerInfo(_serverName, _serverAddress); return new ConnectionTag(newcon); } else { bool pp_found = (sshp.Passphrase!=null && sshp.Passphrase.Length>0); if(sshp.Method==ConnectionMethod.SSH1 && !pp_found) throw new ApplicationException(GEnv.Strings.GetString("Message.SSHTerminalConnection.ReproduceErrorOnSSH1")); if(sshp.Method==ConnectionMethod.SSH2 && !pp_found && this.IsClosed) throw new ApplicationException(GEnv.Strings.GetString("Message.SSHTerminalConnection.ReproduceErrorOnSSH2")); HostKeyChecker checker = new HostKeyChecker(GEnv.Frame, sshp); return CommunicationUtil.CreateNewConnection(sshp, new HostKeyCheckCallback(checker.CheckHostKeyCallback)); } }
protected override void Negotiate() { SSHConnectionParameter con = new SSHConnectionParameter(); con.Protocol = _param.Method==ConnectionMethod.SSH1? SSHProtocol.SSH1 : SSHProtocol.SSH2; con.CheckMACError = GEnv.Options.SSHCheckMAC; con.UserName = _param.Account; con.Password = _password; con.AuthenticationType = _param.AuthType==AuthType.KeyboardInteractive? AuthenticationType.KeyboardInteractive : _param.AuthType==AuthType.Password? AuthenticationType.Password : AuthenticationType.PublicKey; con.IdentityFile = _param.IdentityFile; con.TerminalWidth = _size.Width; con.TerminalHeight = _size.Height; con.TerminalName = EnumDescAttribute.For(typeof(TerminalType)).GetDescription(_param.TerminalType); con.WindowSize = GEnv.Options.SSHWindowSize; con.PreferableCipherAlgorithms = LocalSSHUtil.ParseCipherAlgorithm(GEnv.Options.CipherAlgorithmOrder); con.PreferableHostKeyAlgorithms = LocalSSHUtil.ParsePublicKeyAlgorithm(GEnv.Options.HostKeyAlgorithmOrder); if(_keycheck!=null) con.KeyCheck += new HostKeyCheckCallback(this.CheckKey); SSHTerminalConnection r = new SSHTerminalConnection(_param, _size.Width, _size.Height); SSHConnection ssh = SSHConnection.Connect(con, r, _socket); if(ssh!=null) { if(GEnv.Options.RetainsPassphrase) _param.Passphrase = _password; //�ڑ��������̂݃Z�b�g r.FixConnection(ssh); if(ssh.AuthenticationResult==AuthenticationResult.Success) r.OpenShell(); r.UsingSocks = _socks!=null; r.SetServerInfo(_param.Host, this.IPAddress); _result = new ConnectionTag(r); } else { throw new IOException(GEnv.Strings.GetString("Message.SSHConnector.Cancelled")); } }