public override void InitUI(ContainerOptions options) { _cipherOrderList.Items.Clear(); string[] co = options.CipherAlgorithmOrder; foreach (string c in co) { _cipherOrderList.Items.Add(c); } _hostKeyBox.SelectedIndex = LocalSSHUtil.ParsePublicKeyAlgorithm(options.HostKeyAlgorithmOrder[0]) == PublicKeyAlgorithm.DSA? 0 : 1; //これはDSA/RSAのどちらかしかない _windowSizeBox.Text = options.SSHWindowSize.ToString(); _retainsPassphrase.Checked = options.RetainsPassphrase; _sshCheckMAC.Checked = options.SSHCheckMAC; _cipherAlgorithmOrder = options.CipherAlgorithmOrder; }
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.TerminalName = "xterm"; 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; } 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")); } }
public override bool Commit(ContainerOptions options) { //暗号アルゴリズム順序はoptionsを直接いじっているのでここでは何もしなくてよい try { PublicKeyAlgorithm[] pa = new PublicKeyAlgorithm[2]; if (_hostKeyBox.SelectedIndex == 0) { pa[0] = PublicKeyAlgorithm.DSA; pa[1] = PublicKeyAlgorithm.RSA; } else { pa[0] = PublicKeyAlgorithm.RSA; pa[1] = PublicKeyAlgorithm.DSA; } options.HostKeyAlgorithmOrder = LocalSSHUtil.FormatPublicKeyAlgorithmList(pa); try { options.SSHWindowSize = Int32.Parse(_windowSizeBox.Text); } catch (FormatException) { GUtil.Warning(this, GApp.Strings.GetString("Message.OptionDialog.InvalidWindowSize")); return(false); } options.RetainsPassphrase = _retainsPassphrase.Checked; options.SSHCheckMAC = _sshCheckMAC.Checked; options.CipherAlgorithmOrder = _cipherAlgorithmOrder; return(true); } catch (Exception ex) { GUtil.Warning(this, ex.Message); return(false); } }