Based on JSch-0.1.30
Наследование: ChannelSession
Пример #1
0
 public InputStreamGet(
     ChannelSftp sftp,
     byte[] handle,
     SftpProgressMonitor monitor)
 {
     this.sftp    = sftp;
     this.handle  = handle;
     this.monitor = monitor;
 }
Пример #2
0
 internal OutputStreamPut(ChannelSftp sftp,
     byte[] handle,
     long[] _offset,
     SftpProgressMonitor monitor)
     : base()
 {
     this.sftp=sftp;
     this.handle=handle;
     this._offset=_offset;
     this.monitor=monitor;
 }
Пример #3
0
 internal OutputStreamPut
     (ChannelSftp sftp,
     byte[] handle,
     long[] _offset,
     SftpProgressMonitor monitor) : base()
 {
     this.sftp    = sftp;
     this.handle  = handle;
     this._offset = _offset;
     this.monitor = monitor;
 }
Пример #4
0
		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 = "";
		}
Пример #5
0
 //连接SFTP        
 public bool Connect()
 {
     try
     {
         if (!Connected)
         {
             m_session.connect();
             m_channel = m_session.openChannel("sftp");
             m_channel.connect();
             m_sftp = (ChannelSftp)m_channel;
         }
         return true;
     }
     catch
     {
         return false;
     }
 }
Пример #6
0
		public override void Shutdown()
		{
			if (_csftp != null)
			{
				_csftp.disconnect();
				_csftp = null;
			}

			if (_session != null)
			{
				_session.disconnect();
				_session = null;
			}

			if (_jsch != null)
			{
				_jsch = null;
			}
		}
Пример #7
0
        //连接SFTP
        public bool Connect()
        {
            try
            {
                if (!Connected)
                {
                    m_session.connect();
                    m_channel = m_session.openChannel("sftp");
                    m_channel.connect();
                    m_sftp = (ChannelSftp)m_channel;

                }
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine("host:" + m_session.getHost() + "port:" + m_session.getPort());
                Console.WriteLine(ex.Message);
                throw new Exception(ex.Message + "\r\n" + "host:" + m_session.getHost() + "port:" + m_session.getPort());
                //return false;
            }
        }
Пример #8
0
 private void CleanUp()
 {
     if (_ftp != null)
     {
         try
         {
             if (_ftp.isConnected())
                 _ftp.disconnect();
         }
         finally
         {
             _ftp = null;
         }
     }
     #if DEBUG
     GC.SuppressFinalize(this); // Disarm lock-release checker
     #endif
 }
Пример #9
0
 private SftpObjectDatabase(SftpObjectDatabase parent, string p, TransportSftp instance)
 {
     this._instance = instance;
     try
     {
         _ftp = instance.NewSftp();
         _ftp.cd(parent._objectsPath);
         _ftp.cd(p);
         _objectsPath = _ftp.pwd();
     }
     catch (TransportException)
     {
         CleanUp();
         throw;
     }
     catch (SftpException je)
     {
         throw new TransportException("Can't enter " + p + " from " + parent._objectsPath + ": " + je.message, je);
     }
 }
Пример #10
0
            public SftpObjectDatabase(string path, TransportSftp instance)
            {
                this._instance = instance;

                if (path.StartsWith("/~"))
                {
                    path = path.Substring(1);
                }

                if (path.StartsWith("~/"))
                {
                    path = path.Substring(2);
                }

                try
                {
                    _ftp = instance.NewSftp();
                    _ftp.cd(path);
                    _ftp.cd("objects");
                    _objectsPath = _ftp.pwd();
                }
                catch (TransportException)
                {
                    CleanUp();
                    throw;
                }
                catch (SftpException je)
                {
                    throw new TransportException("Can't enter " + path + "/objects: " + je.message, je);
                }
            }
Пример #11
0
			public InputStreamGet( 
				ChannelSftp sftp,
				byte[] handle,
				SftpProgressMonitor monitor)
			{
				this.sftp=sftp;
				this.handle=handle;
				this.monitor=monitor;
			}
Пример #12
0
 public override void close()
 {
     if (_ftp != null)
     {
         try
         {
             if (_ftp.isConnected())
                 _ftp.disconnect();
         }
         finally
         {
             _ftp = null;
         }
     }
     #if DEBUG
     GC.SuppressFinalize(this); // Disarm lock-release checker
     #endif
 }
Пример #13
0
 public override void close()
 {
     if (_ftp != null)
     {
         try
         {
             if (_ftp.isConnected())
                 _ftp.disconnect();
         }
         finally
         {
             _ftp = null;
         }
     }
 }
Пример #14
0
        private void Conectar()
        {
            JSch jsch = new JSch();
            Hashtable propiedades = new Hashtable();

            this.session=jsch.getSession(this.user, this.host, this.port);
            this.session.setPassword(this.psw);
            this.session.setTimeout(this.timeOut);

            propiedades.Add("password", this.psw);
            propiedades.Add("StrictHostKeyChecking", "no");

            this.session.setConfig(propiedades);
            this.session.connect();

            this.canal = session.openChannel("sftp");
            this.canal.connect();
            this.canalsftp = (ChannelSftp)canal;
        }
Пример #15
0
        private void sftp_login()
        {
            JSch jsch = new JSch();

            String host = tHost.Text;
            String user = tUsername.Text;

            Session session = jsch.getSession(user, host, 22);

            // username and password will be given via UserInfo interface.
            UserInfo ui = new MyUserInfo();

            session.setUserInfo(ui);

            session.setPort(Convert.ToInt32(nPort.Value));

            session.connect();

            Channel channel = session.openChannel("sftp");
            channel.connect();
            sftpc = (ChannelSftp)channel;
        }
Пример #16
0
        ///SFTP Code Starting here
        ///hell yeah
        private void sftp_login()
        {
            JSch jsch = new JSch();

            String host = ftpHost();
            String user = ftpUser();

            Session session = jsch.getSession(user, host, 22);

            // username and password will be given via UserInfo interface.
            UserInfo ui = new MyUserInfo();

            session.setUserInfo(ui);

            session.setPort(ftpPort());

            session.connect();

            Channel channel = session.openChannel("sftp");
            channel.connect();
            sftpc = (ChannelSftp)channel;
            //sftpc = (ChannelSftp)channel;
        }
Пример #17
0
        private void sftp_login()
        {
            JSch jsch = new JSch();

            host = ((frmMain)this.Tag).ftpHost();
            UN = ((frmMain)this.Tag).ftpUser();
            port = ((frmMain)this.Tag).ftpPort();

            Session session = jsch.getSession(UN, host, 22);

            // username and password will be given via UserInfo interface.
            UserInfo ui = new MyUserInfo();

            session.setUserInfo(ui);

            session.setPort(port);

            session.connect();

            Channel channel = session.openChannel("sftp");
            channel.connect();
            sftpc = (ChannelSftp)channel;
        }