示例#1
0
        private void ConfigureSshConnection(string userName, string password)
        {
            this.sshProtocol = new Protocol();
            this.sshProtocol.setTerminalParams(this.term.TerminalType, this.term.Rows, this.term.Columns);
            this.sshProtocol.OnDataIndicated += this.term.IndicateData;
            this.sshProtocol.OnDisconnect    += this.OnDisconnected;
            this.term.OnDataRequested        += this.sshProtocol.RequestData;

            String key = String.Empty;

            KeyConfigElement keyConfigElement = Settings.SSHKeys.Keys[this.Favorite.KeyTag];

            if (keyConfigElement != null)
            {
                key = keyConfigElement.Key;
            }

            this.sshProtocol.setProtocolParams(this.Favorite.AuthMethod, userName, password, key, this.Favorite.Ssh1);

            this.sshProtocol.Connect(this.client);
            this.connected = true; // SSH will throw if fails
        }
示例#2
0
        private string ConfigureSshConnection(IGuardedSecurity security)
        {
            this.sshProtocol = new SSHClient.Protocol();
            this.sshProtocol.setTerminalParams(term.TerminalType, term.Rows, term.Columns);
            this.sshProtocol.OnDataIndicated += term.IndicateData;
            this.sshProtocol.OnDisconnect    += this.OnDisconnected;
            term.OnDataRequested             += this.sshProtocol.RequestData;

            String           key              = String.Empty;
            var              options          = this.Favorite.ProtocolProperties as SshOptions;
            KeyConfigElement keyConfigElement = this.Settings.SSHKeys.Keys[options.CertificateKey];

            if (keyConfigElement != null)
            {
                key = keyConfigElement.Key;
            }

            this.sshProtocol.setProtocolParams(options.AuthMethod, security.UserName, security.Password, key, options.SSH1, options.SSHKeyFile);

            this.sshProtocol.Connect(client);
            this.connected = true; // SSH will throw if fails
            return((options.SSH1) ? "SSH1" : "SSH2");
        }