src/SSHClient.php
public function connect()
	{
		//Attempt to connect to host
		$link = ssh2_connect($this->_config['host'], $this->_config['port']);
		
		//If host connection fails, throw exception
		if(!$link)
		{
			throw new \Exception('Unable to connect to '.$host.' on port '.$port);
		}
		else
		{
			//Assign the connection link to the class property
			$this->_conn_link = $link;
			
			//If host fingerprint is not NULL, attempt to verify fingerprint
			if(!is_null($this->_config['host_fingerprint'])) 
			{
				$verify = $this->verify_host_fingerprint();
				
				//If the fingerprint is not verified, throw exception
				if(!$verify)
				{
					throw new \Exception('Unable to verify host fingerprint');
				}
			}
		}
		
		//Attempt to login user
		if($this->_config['authentication_method'] == 'KEY')
		{
			$this->_connected = $this->login_key();
		}
		else
		{
			$this->_connected = $this->login_password();
		}

		$this->_connected && $this->_sftp = ssh2_sftp($link);
	}
public function connect()
	{
		//Attempt to connect to host
		$link = ssh2_connect($this->_config['host'], $this->_config['port']);
		
		//If host connection fails, throw exception
		if(!$link)
		{
			throw new \Exception('Unable to connect to '.$host.' on port '.$port);
		}
		else
		{
			//Assign the connection link to the class property
			$this->_conn_link = $link;
			
			//If host fingerprint is not NULL, attempt to verify fingerprint
			if(!is_null($this->_config['host_fingerprint'])) 
			{
				$verify = $this->verify_host_fingerprint();
				
				//If the fingerprint is not verified, throw exception
				if(!$verify)
				{
					throw new \Exception('Unable to verify host fingerprint');
				}
			}
		}
		
		//Attempt to login user
		if($this->_config['authentication_method'] == 'KEY')
		{
			$this->_connected = $this->login_key();
		}
		else
		{
			$this->_connected = $this->login_password();
		}

		$this->_connected && $this->_sftp = ssh2_sftp($link);
	}
public function connect ( ) { //Attempt to connect to host $ link = ssh2_connect ( $ this -> _config [ 'host' ] , $ this -> _config [ 'port' ] ) ; //If host connection fails, throw exception if ( ! $ link ) { throw new \ Exception ( 'Unable to connect to ' . $ host . ' on port ' . $ port ) ; } else { //Assign the connection link to the class property $ this -> _conn_link = $ link ; //If host fingerprint is not NULL, attempt to verify fingerprint if ( ! is_null ( $ this -> _config [ 'host_fingerprint' ] ) ) { $ verify = $ this -> verify_host_fingerprint ( ) ; //If the fingerprint is not verified, throw exception if ( ! $ verify ) { throw new \ Exception ( 'Unable to verify host fingerprint' ) ; } } } //Attempt to login user if ( $ this -> _config [ 'authentication_method' ] == 'KEY' ) { $ this -> _connected = $ this -> login_key ( ) ; } else { $ this -> _connected = $ this -> login_password ( ) ; } $ this -> _connected && $ this -> _sftp = ssh2_sftp ( $ link ) ; }
Connect to host

Connects to the host.  Throws exception if the host is unable to be connected to.  Will automatically
verify the host fingerprint, if one was provided, and throw an exception if the fingerprint is not
verified.
Connect to host