Ejemplo n.º 1
0
 public TelnetConnection(SSHConnectionParameter param, ISSHConnectionEventReceiver r, StreamSocket s)
 {
     _param = (SSHConnectionParameter)param.Clone();
     _eventReceiver = r;
     _autoDisconnect = true;
     socket = s;
 }
Ejemplo n.º 2
0
        public SSH2Connection(SSHConnectionParameter param, ISSHConnectionEventReceiver r, string serverversion, string clientversion)
        {
            _param = (SSHConnectionParameter)param.Clone();
            _eventReceiver = r;
            _channel_entries = new List<object>(16);
            _autoDisconnect = true;
            _cInfo = new SSH2ConnectionInfo();
            _cInfo._serverVersionString = serverversion;
            _cInfo._clientVersionString = clientversion;

            _packetBuilder = new SSH2PacketBuilder(new SynchronizedSSH2PacketHandler());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// STart new class
        /// </summary>
        /// <param name="param"></param>

        public ProtocolNegotiationHandler(SSHConnectionParameter param)
        {
            _event        = new ManualResetEvent(false);
            _param        = param;
            _errorMessage = Strings.GetString("NotSSHServer");
        }
Ejemplo n.º 4
0
        /// <summary>
        /// STart new class
        /// </summary>
        /// <param name="param"></param>

		public ProtocolNegotiationHandler(SSHConnectionParameter param) {
            _event = new ManualResetEvent(false);
			_param = param;
			_errorMessage = Strings.GetString("NotSSHServer");
		}
Ejemplo n.º 5
0
 public static TelnetConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, StreamSocket underlying_socket)
 {
     return new TelnetConnection(param, receiver, underlying_socket);
 }
Ejemplo n.º 6
0
 public object Clone()
 {
     SSHConnectionParameter n = new SSHConnectionParameter();
     n._authtype = _authtype;
     n._cipherAlgorithms = _cipherAlgorithms;
     n._height = _height;
     n._hostkeyAlgorithms = _hostkeyAlgorithms;
     n._identityFile = _identityFile;
     n._keycheck = _keycheck;
     n._maxpacketsize = _maxpacketsize;
     n._password = _password;
     n._protocol = _protocol;
     n._random = _random;
     n._terminalname = _terminalname;
     n._username = _username;
     n._width = _width;
     n._windowsize = _windowsize;
     n._checkMACError = _checkMACError;
     return n;
 }
Ejemplo n.º 7
0
        //establishes a SSH connection in subject to ConnectionParameter
        public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, StreamSocket underlying_socket)
        {
            if (param.UserName == null) throw new InvalidOperationException(resLoader.GetString("UsernameUnset"));
            if (param.Password == null) throw new InvalidOperationException(resLoader.GetString("PasswordUnset"));

            ProtocolNegotiationHandler pnh = new ProtocolNegotiationHandler(param);
            PlainSocket s = new PlainSocket(underlying_socket, pnh);
            s.RepeatAsyncRead();
            return ConnectMain(param, receiver, pnh, s);
        }
Ejemplo n.º 8
0
 public KeyExchanger(SSH2Connection con, byte[] sessionID)
 {
     _con = con;
     _param = con.Param();
     _cInfo = (SSH2ConnectionInfo)con.ConnectionInfo();
     _sessionID = sessionID;
     _status = Status.INITIAL;
 }
Ejemplo n.º 9
0
 private static void SendMyVersion(AbstractSocket stream, SSHConnectionParameter param)
 {
     string cv = SSHUtil.ClientVersionString(param.Protocol);
     if (param.Protocol == SSHProtocol.SSH1)
         cv += param.SSH1VersionEOL;
     else
         cv += "\r\n";
     byte[] data = Encoding.UTF8.GetBytes(cv);
     stream.Write(data, 0, data.Length);
 }
Ejemplo n.º 10
0
        private static SSHConnection ConnectMain(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            pnh.Wait();

            if (pnh.State != ReceiverState.Ready) throw new Exception(pnh.ErrorMessage);

            string sv = pnh.ServerVersion;

            SSHConnection con = null;
            //if (param.Protocol == SSHProtocol.SSH1)
            //    con = new SSH1Connection(param, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));
            //else
                con = new SSH2Connection(param, receiver, sv, SSHUtil.ClientVersionString(param.Protocol));

            s.SetHandler(con.PacketBuilder());
            SendMyVersion(s, param);

            if (con.DoConnect(s) != GranadosRT.Routrek.SSHC.AuthenticationResult.Failure)
                return con;
            else
            {
                s.Close();
                throw new Exception(Strings.GetString("AuthenticationFailed"));
                //return null;
            }
        }
Ejemplo n.º 11
0
        /**
         * opens another SSH connection via port-forwarded connection
         */
        public SSHConnection OpenPortForwardedAnotherConnection(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, string host, int port)
        {
            ProtocolNegotiationHandler pnh = new ProtocolNegotiationHandler(param);
            ChannelSocket s = new ChannelSocket(pnh);

            SSHChannel ch = ForwardPort(s, host, port, "localhost", 0);
            s.SSHChennal = ch;
            return SSH2Connection.Connect(param, receiver, pnh, s);
        }
Ejemplo n.º 12
0
        public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            if (param.UserName == null) throw new InvalidOperationException(resLoader.GetString("UsernameUnset"));
            if (param.Password == null) throw new InvalidOperationException(resLoader.GetString("PasswordUnset"));

            return ConnectMain(param, receiver, pnh, s);
        }
Ejemplo n.º 13
0
        public static SSHConnection Connect(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, ProtocolNegotiationHandler pnh, AbstractSocket s)
        {
            if (param.UserName == null) throw new InvalidOperationException("UserName property is not set");
            if (param.Password == null) throw new InvalidOperationException("Password property is not set");

            return ConnectMain(param, receiver, pnh, s);
        }