예제 #1
0
 public void Connect()
 {
     if (IsConnected)
     {
         throw new Exception("Already connected!");
     }
     Ssh.Connect();
     Sftp.Connect();
     IsConnected = true;
 }
 private bool ConnectSsh(string hostAddrs, string userName, string password, ref string reply, ref Ssh ssh)
 {
     ssh = new Ssh();
     ssh.Subscribe(OnIncomingSsh);
     if (ssh.Connect(hostAddrs, userName, password, ref reply))
     {
         ssh.CreateShellStream("terminal", 80, 24, 800, 600, 1024); //TODO: CHANGE THIS ACCORDING TO WINDOW SIZE, FOR LONG LINES PRINTING
         return(true);
     }
     return(false);
 }
예제 #3
0
파일: Accueil.cs 프로젝트: secretMoi/MySyno
 private void buttonConnexion_Click(object sender, System.EventArgs e)
 {
     if (Ssh.IsConnected)
     {
         Ssh.Disconnect();
     }
     else
     {
         Ssh.Connect();
     }
 }
예제 #4
0
        public override Server creack(string ip, int port, string username, string password, int timeOut)
        {
            Ssh    ssh    = new Ssh();
            Server server = new Server();

            ssh.Timeout = timeOut * 1000;
            try
            {
                ssh.Connect(ip);
                if (ssh.IsConnected)
                {
                    ssh.Login(username, password);
                    if (ssh.IsAuthenticated)
                    {
                        server.isSuccess = true;
                        server.banner    = ssh.ServerKey.Comment;
                    }
                }
            }
            catch (Exception e)
            {
                if (e.Message.IndexOf("incorrect") != -1)
                {
                    return(server);
                }
                else
                {
                    throw e;
                }
            }
            finally
            {
                ssh.Disconnect();
            }
            return(server);
        }
예제 #5
0
        public void Connect()
        {
            lock (this) {
                if (IsConnected)
                {
                    throw new Exception("Already connected!");
                    IsConnected = true;
                }
            }
            Ssh.Connect();
            Sftp.Connect();

            var forwardLocal  = new ForwardedPortLocal("127.0.0.1", MonoEngine.MonoDebuggerPort, "127.0.0.1", MonoEngine.MonoDebuggerPort);
            var forwardRemote = new ForwardedPortRemote("127.0.0.1", MonoEngine.MonoDebuggerPort, "127.0.0.1", MonoEngine.MonoDebuggerPort);

            Ssh.AddForwardedPort(forwardLocal);
            Ssh.AddForwardedPort(forwardRemote);

            forwardLocal.Exception  += (sender, e) => { throw e.Exception; };
            forwardRemote.Exception += (sender, e) => { throw e.Exception; };

            forwardLocal.Start();
            forwardRemote.Start();
        }