Пример #1
0
        protected virtual void OpenSshSessionIfNecessary(bool usingSsh, string sshRemoteHost, string sshUser, string sshPassword, string privateKey, int sshPort, int productPort)
        {
            if (usingSsh)
            {
                Durados.Security.Ssh.ITunnel tunnel = new Durados.DataAccess.Ssh.Tunnel();

                tunnel.RemoteHost = sshRemoteHost;
                tunnel.User       = sshUser;
                tunnel.Password   = sshPassword;
                tunnel.PrivateKey = privateKey;
                tunnel.Port       = sshPort;
                int remotePort = productPort;
                localPort = Maps.Instance.AssignLocalPort();

                session = new Durados.DataAccess.Ssh.ChilkatSession(tunnel, remotePort, localPort);
                session.Open(15);
            }
        }
Пример #2
0
        private void OpenSshSessionIfNecessary(DataActionEventArgs e)
        {
            bool usingSsh = e.Values.ContainsKey(SshUses) && !e.Values[SshUses].Equals(string.Empty) ? Convert.ToBoolean(e.Values[SshUses]) : false;

            if (usingSsh)
            {
                Durados.Security.Ssh.ITunnel tunnel = new Durados.DataAccess.Ssh.Tunnel();

                tunnel.RemoteHost = e.Values.ContainsKey(SshRemoteHost) ? e.Values[SshRemoteHost].ToString() : string.Empty;
                tunnel.User       = e.Values.ContainsKey(SshUser) ? e.Values[SshUser].ToString() : string.Empty;
                tunnel.Password   = e.Values.ContainsKey(SshPassword) ? e.Values[SshPassword].ToString() : string.Empty;
                tunnel.PrivateKey = e.Values.ContainsKey(SshPrivateKey) ? e.Values[SshPrivateKey].ToString() : string.Empty;
                tunnel.Port       = e.Values.ContainsKey(SshPort) && !e.Values[SshPort].Equals(string.Empty) ? Convert.ToInt32(e.Values[SshPort]) : 22;
                int remotePort = e.Values.ContainsKey(ProductPort) && !e.Values[ProductPort].Equals(string.Empty) ? Convert.ToInt32(e.Values[ProductPort]) : 3306;
                localPort = Maps.Instance.AssignLocalPort();

                session = new Durados.DataAccess.Ssh.ChilkatSession(tunnel, remotePort, localPort);
                session.Open();
            }
        }