• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# jsch.Session类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Tamir.SharpSsh.jsch.Session的典型用法代码示例。如果您正苦于以下问题:C# Session类的具体用法?C# Session怎么用?C# Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Session类属于Tamir.SharpSsh.jsch命名空间,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: getPort

		internal static PortWatcher getPort(Session session, String address, int lport)
		{
			IPAddress addr;
			try
			{
				addr = Dns.GetHostEntry(address).AddressList[0];
			}
			catch(Exception)
			{
				throw new JSchException("PortForwardingL: invalid address "+address+" specified.");
			}
			lock(pool)
			{
				for(int i=0; i<pool.Count; i++)
				{
					PortWatcher p=(PortWatcher)(pool[i]);
					if(p.session==session && p.lport==lport)
					{

						if (
							IPAddress.IsLoopback(p.boundaddress) ||
							p.boundaddress == addr
						)
						{
							return p;
						}
					}
				}
				return null;
			}
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:31,代码来源:PortWatcher.cs


示例3: getFakedCookie

		internal static byte[] getFakedCookie(Session session)
		{
			lock(faked_cookie_hex_pool)
			{
				byte[] foo=(byte[])faked_cookie_hex_pool[session];
				if(foo==null)
				{
					Random random=Session.random;
					foo=new byte[16];
					lock(random)
					{
						random.fill(foo, 0, 16);
					}
					/*
					System.out.print("faked_cookie: ");
					for(int i=0; i<foo.length; i++){
						System.out.print(Integer.toHexString(foo[i]&0xff)+":");
					}
					System.out.println("");
					*/
					faked_cookie_pool.Add(session, foo);
					byte[] bar=new byte[32];
					for(int i=0; i<16; i++)
					{
						bar[2*i]=table[(foo[i]>>4)&0xf];
						bar[2*i+1]=table[(foo[i])&0xf];
					}
					faked_cookie_hex_pool.Add(session, bar);
					foo=bar;
				}
				return foo;
			}
		}
开发者ID:MatanDavidCohen,项目名称:StockAnalyzerWin,代码行数:33,代码来源:ChannelX11.cs


示例4: 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


示例5: request

		public void request(Session session, Channel channel)
		{
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);

			bool reply=waitForReply();
			if(reply)
			{
				channel.reply=-1;
			}

			packet.reset();
			buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(Util.getBytes("subsystem"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putString(Util.getBytes("sftp"));
			session.write(packet);

			if(reply)
			{
				while(channel.reply==-1)
				{
					try{System.Threading.Thread.Sleep(10);}
					catch//(Exception ee)
					{
					}
				}
				if(channel.reply==0)
				{
					throw new JSchException("failed to send sftp request");
				}
			}
		}
开发者ID:stux2000,项目名称:dokan,代码行数:34,代码来源:RequestSftp.cs


示例6: getPort

		internal static PortWatcher getPort(Session session, String address, int lport)
		{
			InetAddress addr;
			try
			{
				addr=InetAddress.getByName(address);
			}
			catch(Exception uhe)
			{
				throw new JSchException("PortForwardingL: invalid address "+address+" specified.");
			}
			lock(pool)
			{
				for(int i=0; i<pool.size(); i++)
				{
					PortWatcher p=(PortWatcher)(pool.elementAt(i));
					if(p.session==session && p.lport==lport)
					{
						if(p.boundaddress.isAnyLocalAddress() ||
							p.boundaddress.equals(addr))
							return p;
					}
				}
				return null;
			}
		}
开发者ID:MatanDavidCohen,项目名称:StockAnalyzerWin,代码行数:26,代码来源:PortWatcher.cs


示例7: Connect

        public static void Connect()
        {
            try
             {
                 var jsch = new JSch();

                 _session = jsch.getSession(Settings.SSHUsername, Settings.SSHHost, Settings.SSHPort);
                 _session.setHost(Settings.SSHHost);
                 _session.setPassword(Settings.SSHPassword);
                 UserInfo ui = new MyUserInfo(Settings.SSHPassword);
                 _session.setUserInfo(ui);
                 _session.connect();
                 int port;
                 if (!int.TryParse(Settings.Port, out port))
                     port = 3306;
                 _session.setPortForwardingL(Settings.SSHLocalPort, "localhost", port);
                 if (!_session.isConnected())
                    Enabled = false;
             }
             catch (Exception ex)
             {
                Enabled = false;
                Trace.WriteLine(ex.Message + " at ssh connect.");
                Disconnect();
            }
        }
开发者ID:Chaplain,项目名称:WowPacketParser,代码行数:26,代码来源:SSHTunnel.cs


示例8: configure

 protected override void configure(OpenSshConfig.Host hc, Session session)
 {
     if (!hc.isBatchMode())
     {
     #warning need something to replace jgit gui infrastructure as gitsharp is library only
         throw new NotImplementedException("GUI Configuration is not available");
     }
 }
开发者ID:georgeck,项目名称:GitSharp,代码行数:8,代码来源:DefaultSshSessionFactory.cs


示例9: releaseSession

        public void releaseSession(Session session)
        {
            if (session == null)
                throw new System.ArgumentNullException ("session");

            if (session.isConnected())
                session.disconnect();
        }
开发者ID:stschake,项目名称:GitSharp,代码行数:8,代码来源:SshSessionFactory.cs


示例10: SftpHelper

 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="host"></param>
 /// <param name="user"></param>
 /// <param name="pwd"></param>
 public SftpHelper(string host, string user, string pwd)
 {
     string[] arr = host.Split(':');
     string ip = arr[0];
     int port = 22;
     if (arr.Length > 1) port = Int32.Parse(arr[1]);
     JSch jsch = new JSch();
     m_session = jsch.getSession(user, ip, port);
     MyUserInfo ui = new MyUserInfo();
     ui.setPassword(pwd);
     m_session.setUserInfo(ui);
 }
开发者ID:rexyanglucky,项目名称:uba,代码行数:18,代码来源:SftpHelper.cs


示例11: init

		public override void init(Session session,
			byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C) 
		{
			this.session=session;
			this.V_S=V_S;      
			this.V_C=V_C;      
			this.I_S=I_S;      
			this.I_C=I_C;      

			//    sha=new SHA1();
			//    sha.init();
			try
			{
				Type t=Type.GetType(session.getConfig("sha-1"));
				sha=(HASH)(Activator.CreateInstance(t));
				sha.init();
			}
			catch(Exception ee)
			{
				Console.WriteLine(ee);
			}

			buf=new Buffer();
			packet=new Packet(buf);

			try
			{
				Type t=Type.GetType(session.getConfig("dh"));
				dh=(DH)(Activator.CreateInstance(t));
				dh.init();
			}
			catch(Exception ee)
			{
				throw ee;
			}

			dh.setP(p);
			dh.setG(g);

			// The client responds with:
			// byte  SSH_MSG_KEXDH_INIT(30)
			// mpint e <- g^x mod p
			//         x is a random number (1 < x < (p-1)/2)

			e=dh.getE();

			packet.reset();
			buf.putByte((byte)SSH_MSG_KEXDH_INIT);
			buf.putMPInt(e);
			session.write(packet);

			state=SSH_MSG_KEXDH_REPLY;
		}
开发者ID:stux2000,项目名称:dokan,代码行数:53,代码来源:DHG1.cs


示例12: getChannel

		internal static Channel getChannel(int id, Session session)
		{
			lock(pool)
			{
				for(int i=0; i<pool.Count; i++)
				{
					Channel c=(Channel)(pool[i]);
					if(c.id==id && c.session==session) return c;
				}
			}
			return null;
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:12,代码来源:Channel.cs


示例13: getChannel

		internal static Channel getChannel(int id, Session session)
		{
			lock(pool)
			{
				for(int i=0; i<pool.size(); i++)
				{
					Channel c=(Channel)(pool.elementAt(i));
					if(c.id==id && c.session==session) return c;
				}
			}
			return null;
		}
开发者ID:MatanDavidCohen,项目名称:StockAnalyzerWin,代码行数:12,代码来源:Channel.cs


示例14: request

		public void request(Session session, Channel channel)
		{
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);

			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString( Util.getBytes("signal"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putString(Util.getBytes(signal));
			session.write(packet);
		}
开发者ID:MatanDavidCohen,项目名称:StockAnalyzerWin,代码行数:13,代码来源:RequestSignal.cs


示例15: _Connect

		protected void _Connect()
		{
			_jsch = new JSch();
			//session.setConfig();
			_session = _jsch.getSession(this.Username, this.Host, this.Port);
			UserInfo ui = new DirectPasswordUserInfo(this.Password);
			_session.setUserInfo(ui);
			_session.connect();

			_csftp = (ChannelSftp)_session.openChannel("sftp");
			_csftp.connect();

			//RootPath = csftp.getHome();
			RootPath = "";
		}
开发者ID:soywiz,项目名称:csharputils,代码行数:15,代码来源:SftpFileSystem.cs


示例16: Connect

 public void Connect(string User, string Password, string Host, int Port)
 {
     this.Host = Host;
     this.Username = User;
     this.Password = Password;
     this.Port = Port;
     this.session = this.handler.getSession(this.Username, this.Host, this.Port);
     this.session.setHost(this.Host);
     this.session.setPassword(this.Password);
     this.session.setUserInfo(this.UInfo);
     Hashtable config = new Hashtable();
     config.Add("StrictHostKeyChecking", "no");
     this.session.setConfig(config); 
     this.session.connect();
 }
开发者ID:TheoBo,项目名称:Wallet.Net,代码行数:15,代码来源:SSHCore.cs


示例17: init

        //private byte[] f;
        public override void init(Session session,
            byte[] V_S, byte[] V_C, byte[] I_S, byte[] I_C)
        {
            this.session = session;
            this.V_S = V_S;
            this.V_C = V_C;
            this.I_S = I_S;
            this.I_C = I_C;

            //    sha=new SHA1();
            //    sha.init();

            try
            {
                Type t = Type.GetType(session.getConfig("sha-1"));
                sha = (HASH) (Activator.CreateInstance(t));
                sha.init();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            buf = new Buffer();
            packet = new Packet(buf);

            try
            {
                Type t = Type.GetType(session.getConfig("dh"));
                dh = (DH) (Activator.CreateInstance(t));
                dh.init();
            }
            catch (Exception e)
            {
                throw e;
            }

            packet.reset();
            buf.putByte(0x22);
            buf.putInt(min);
            buf.putInt(preferred);
            buf.putInt(max);
            session.write(packet);

            state = SSH_MSG_KEX_DH_GEX_GROUP;
        }
开发者ID:christianz,项目名称:SharpSSH,代码行数:47,代码来源:DHGEX.cs


示例18: request

		public void request(Session session, Channel channel) 
		{
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);

			// send
			// byte     SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type       // "shell"
			// boolean want reply        // 0
			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(Util.getBytes("shell"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			session.write(packet);
		}
开发者ID:stux2000,项目名称:dokan,代码行数:17,代码来源:RequestShell.cs


示例19: request

        public void request(Session session, Channel channel)
        {
            Buffer buf=new Buffer();
            Packet packet=new Packet(buf);

            packet.reset();
            buf.WriteByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
            buf.WriteInt(channel.getRecipient());
            buf.WriteString(Util.getBytes("pty-req"));
            buf.WriteByte((byte)(waitForReply() ? 1 : 0));
            buf.WriteString(Util.getBytes("vt100"));
            buf.WriteInt(80);
            buf.WriteInt(24);
            buf.WriteInt(640);
            buf.WriteInt(480);
            buf.WriteString(Util.getBytes(""));
            session.write(packet);
        }
开发者ID:yash0924,项目名称:csharputils,代码行数:18,代码来源:RequestPtyReq.cs


示例20: request

		public void request(Session session, Channel channel)
		{
			Packet packet=session.packet;
			Buffer buf=session.buf;
			// send
			// byte     SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type       // "exec"
			// boolean want reply        // 0
			// string command
			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(new Str("exec").getBytes());
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putString(new Str(command).getBytes());
			session.write(packet);
		}
开发者ID:MatanDavidCohen,项目名称:StockAnalyzerWin,代码行数:18,代码来源:RequestExec.cs



注:本文中的Tamir.SharpSsh.jsch.Session类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Tango.TangoApplication类代码示例发布时间:2022-05-26
下一篇:
C# jsch.Packet类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap