當前位置: 首頁>>代碼示例>>C#>>正文


C# Session.setConfig方法代碼示例

本文整理匯總了C#中Tamir.SharpSsh.jsch.Session.setConfig方法的典型用法代碼示例。如果您正苦於以下問題:C# Session.setConfig方法的具體用法?C# Session.setConfig怎麽用?C# Session.setConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tamir.SharpSsh.jsch.Session的用法示例。


在下文中一共展示了Session.setConfig方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Connect

 public void Connect()
 {
     InitVAHInfo();
     try
     {
         JSch jsch = new JSch();
         _ssn = jsch.getSession(_usr, _hip, _hp);
         System.Collections.Hashtable hashConfig = new Hashtable();
         hashConfig.Add("StrictHostKeyChecking", "No");
         _ssn.setConfig(hashConfig);
         jsch.addIdentity(_ppk);
         _ssn.connect();
         if (_ssn.isConnected())
         {
             Console.WriteLine("Log Successfully.");
         }
         else
         {
             Console.WriteLine("Log failed.");
         }
     }
     catch (Tamir.SharpSsh.jsch.JSchException jschex)
     {
         Console.WriteLine(jschex.Message);
     }
     catch (Exception anyex)
     {
         Console.WriteLine(anyex.Message);
     }
 }
開發者ID:rogerluo,項目名稱:testcsharp,代碼行數:30,代碼來源:TestShell.cs

示例2: SshHelper

        public SshHelper(string Host, string UserName, string Password)
        {
            host = Host;
            var jsch = new JSch();
            session = jsch.getSession(UserName, host, 22);
            session.setPassword(Password);

            var config = new Hashtable { { "StrictHostKeyChecking", "no" } };
            session.setConfig(config);

            session.connect();

            channel = (ChannelShell)session.openChannel("shell");

            writer_po = new PipedOutputStream();
            var writer_pi = new PipedInputStream(writer_po);

            var reader_pi = new PipedInputStream();
            var reader_po = new PipedOutputStream(reader_pi);
            reader = new StreamReader(reader_pi, Encoding.UTF8);

            channel.setInputStream(writer_pi);
            channel.setOutputStream(reader_po);

            channel.connect();
            channel.setPtySize(132, 132, 1024, 768);
        }
開發者ID:gamchantoi,項目名稱:astra-contact-manager,代碼行數:27,代碼來源:SshHelper.cs

示例3: SshStream

		/// <summary>
		/// Constructs a new SSH stream.
		/// </summary>
		/// <param name="host">The hostname or IP address of the remote SSH machine</param>
		/// <param name="username">The name of the user connecting to the remote machine</param>
		/// <param name="password">The password of the user connecting to the remote machine</param>
		public SshStream(string host, string username, string password)
		{
			this.m_host = host;
			JSch jsch=new JSch();
			m_session=jsch.getSession(username, host, 22);
			m_session.setPassword( password );
		
			Hashtable config=new Hashtable();
			config.Add("StrictHostKeyChecking", "no");
			m_session.setConfig(config);
		
			m_session.connect();
			m_channel=(ChannelShell)m_session.openChannel("shell");

			m_in	= m_channel.getInputStream();
			m_out	= m_channel.getOutputStream();

			m_channel.connect();
			m_channel.setPtySize(80, 132, 1024, 768);

			Prompt = "\n";
			m_escapeCharPattern = "\\[[0-9;?]*[^0-9;]";
		}
開發者ID:MatanDavidCohen,項目名稱:StockAnalyzerWin,代碼行數:29,代碼來源:SshStream.cs

示例4: ConnectSession

		protected virtual void ConnectSession(int tcpPort)
		{
			m_session = m_jsch.getSession(m_user, m_host, tcpPort);
			if (Password != null)
				m_session.setUserInfo(new KeyboardInteractiveUserInfo(Password));
			Hashtable config = new Hashtable();
			config.Add("StrictHostKeyChecking", "no");
			m_session.setConfig(config);
			m_session.connect();
		}
開發者ID:stux2000,項目名稱:dokan,代碼行數:10,代碼來源:SshBase.cs

示例5: SSHConnect

        internal bool SSHConnect()
        {
            try
            {
                channels_ = new Dictionary<int, ChannelSftp>();

                jsch_ = new JSch();
                Hashtable config = new Hashtable();
                config["StrictHostKeyChecking"] = "no";

                if (identity_ != null)
                    jsch_.addIdentity(identity_, passphrase_);

                session_ = jsch_.getSession(user_, host_, port_);
                session_.setConfig(config);
                session_.setUserInfo(new DokanUserInfo(password_, passphrase_));
                session_.setPassword(password_);

                session_.connect();

                return true;
            }
            catch (Exception e)
            {
                Debug(e.ToString());
                return false;
            }
        }
開發者ID:stux2000,項目名稱:dokan,代碼行數:28,代碼來源:DokanOperations.cs

示例6: ScpWebResponse

        /// <summary>
        /// Initiates a new SCP response on sourceforge.net for downloading a file.
        /// </summary>
        /// <param name="uri">URI to download (includes username and password)</param>
        /// <param name="timeout">Timeout for this session</param>
        public ScpWebResponse(Uri uri, int timeout)
        {
            JSch jsch = new JSch();

            string[] userPass = uri.UserInfo.Split(':');
            if (userPass.Length != 2)
            {
                throw new WebException("Username and password information for sourceforge.net incomplete");
            }

            session = jsch.getSession(userPass[0], "frs.sourceforge.net", 22);

            // username and password will be given via UserInfo interface.
            //UserInfo ui = new UserInfo();
            //session.setUserInfo(ui);
            session.setPassword(userPass[1]);
            Hashtable hastable = new Hashtable();
            hastable.put("StrictHostKeyChecking", "no");
            session.setConfig(hastable);

            if (DbManager.Proxy != null)
            {
                session.setProxy(new ProxyHTTP(DbManager.Proxy.Address.Host, DbManager.Proxy.Address.Port));
            }

            try
            {
                session.connect(timeout);
            }
            catch (JSchException e)
            {
                if (e.Message == "Auth fail")
                {
                    throw new WebException("Invalid username or password for sourceforge");
                }
                throw;
            }

            // exec 'scp -f rfile' remotely
            string sfPath = GetSourceforgePath(uri.LocalPath);

            // Determine file modified date
            ChannelSftp channelSftp = (ChannelSftp)session.openChannel("sftp");
            channelSftp.connect();
            try
            {
                SftpATTRS attrs = channelSftp.lstat(sfPath);
                this.lastModified = RpcApplication.UnixToDotNet(attrs.getMTime());
            }
            catch (SftpException)
            {
                throw new WebException("The file \"" + sfPath + "\" could not be found.");
            }
            finally
            {
                channelSftp.disconnect();
            }

            String command = "scp -f " + sfPath.Replace(" ", "\\ ");
            Channel channel = session.openChannel("exec");
            ((ChannelExec)channel).setCommand(command);

            // get I/O streams for remote scp
            Stream outs = channel.getOutputStream();
            Stream ins = channel.getInputStream();

            channel.connect();

            byte[] buf = new byte[1024];

            // send '\0'
            buf[0] = 0; outs.Write(buf, 0, 1); outs.Flush();


            int c = checkAck(ins);
            if (c != 'C')
            {
                return;
            }

            // read '0644 '
            ins.Read(buf, 0, 5);

            while (true)
            {
                ins.Read(buf, 0, 1);
                if (buf[0] == ' ') break;
                this.contentLength = this.contentLength * 10 + (buf[0] - '0');
            }

            String file = null;
            for (int i = 0; ; i++)
            {
                ins.Read(buf, i, 1);
                if (buf[i] == (byte)0x0a)
//.........這裏部分代碼省略.........
開發者ID:RyanGrange,項目名稱:Ketarin,代碼行數:101,代碼來源:Scp.cs

示例7: ConnectSession

        protected virtual void ConnectSession(int tcpPort)
        {
            m_session = m_jsch.getSession(m_user, m_host, tcpPort);

            if (Password != null)
            {
                if (m_userInfo == null)
                    m_userInfo = new DisconnectedKeyboardInteractiveUserInfo(Password);
                else
                    throw new InvalidDataException("Cannot combine a predefined 'UserInfo' object with a predefined 'Password' value.");
            }

            m_session.setUserInfo(m_userInfo);

            //determine how strict to be on host key issues.
            Hashtable config = new Hashtable();
            switch (m_checkType)
            {
                case HostKeyCheckType.AskUser:
                    config.Add("StrictHostKeyChecking", "ask");
                    break;
                case HostKeyCheckType.ForceMatch:
                    config.Add("StrictHostKeyChecking", "yes");
                    break;
                case HostKeyCheckType.NoCheck:
                    config.Add("StrictHostKeyChecking", "no");
                    break;
                default:
                    throw new InvalidDataException("Unknown value provided for 'm_checkType' property");
            }
            m_session.setConfig(config);

            if (m_hostKeyFileName != null)
                m_jsch.getHostKeyRepository().setKnownHosts(m_hostKeyFileName);

            m_session.connect();
        }
開發者ID:akrisiun,項目名稱:SharpSSH,代碼行數:37,代碼來源:SshBase.cs


注:本文中的Tamir.SharpSsh.jsch.Session.setConfig方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。