Index: wp-admin/includes/class-wp-filesystem-ssh2.php
===================================================================
--- wp-admin/includes/class-wp-filesystem-ssh2.php	(revision 8812)
+++ wp-admin/includes/class-wp-filesystem-ssh2.php	(working copy)
@@ -9,6 +9,31 @@
 /**
  * WordPress Filesystem Class for implementing SSH2.
  *
+ * To use this class you must follow these steps for PHP 5.2.6+
+ * 
+ * @contrib http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/ - Installation Notes
+ * 
+ * Complie libssh2 (Note: Only 0.14 is officaly working with PHP 5.2.6+ right now.)
+ * 
+ * cd /usr/src
+ * wget http://surfnet.dl.sourceforge.net/sourceforge/libssh2/libssh2-0.14.tar.gz
+ * tar -zxvf libssh2-0.14.tar.gz
+ * cd libssh2-0.14/
+ * ./configure
+ * make all install
+ * 
+ * Note: No not leave the directory yet!
+ * 
+ * Enter: pecl install -f ssh2
+ * 
+ * Copy the ssh.so file it creates to your PHP Module Directory.
+ * Open up your PHP.INI file and look for where extensions are placed.
+ * Add in your PHP.ini file: extension=ssh2.so
+ * 
+ * Restart Apache!
+ * Check phpinfo() streams to confirm that: ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp  exist.
+ * 
+ * 
  * @since 2.7
  * @package WordPress
  * @subpackage Filesystem
@@ -23,23 +48,8 @@
 	var $errors = array();
 	var $options = array();
 
-	var $permission = null;
+	var $permission = 0644;
 
-	var $filetypes = array(
-							'php'=>FTP_ASCII,
-							'css'=>FTP_ASCII,
-							'txt'=>FTP_ASCII,
-							'js'=>FTP_ASCII,
-							'html'=>FTP_ASCII,
-							'htm'=>FTP_ASCII,
-							'xml'=>FTP_ASCII,
-
-							'jpg'=>FTP_BINARY,
-							'png'=>FTP_BINARY,
-							'gif'=>FTP_BINARY,
-							'bmp'=>FTP_BINARY
-							);
-
 	function WP_Filesystem_SSH2($opt='') {
 		$this->method = 'ssh2';
 		$this->errors = new WP_Error();
@@ -71,7 +81,7 @@
 			$this->options['username'] = $opt['username'];
 
 		if ( empty ($opt['password']) )
-			$this->errors->add('empty_password', __('SSH password is required'));
+			$this->errors->add('empty_password', __('SSH2 password is required'));
 		else
 			$this->options['password'] = $opt['password'];
 
@@ -96,26 +106,25 @@
 	
 	function run_command($link, $command, $returnbool = false) {
 		$this->debug("run_command(".$command.");");
-		if(!($stream = @ssh2_exec( $link, $command ))) {
-            $this->errors->add('command', sprintf(__('Unable to preform command: %s'), $command));
-        } else {
-            stream_set_blocking( $stream, true );
+		if( ! ($stream = @ssh2_exec( $link, $command )) ) {
+			$this->errors->add('command', sprintf(__('Unable to preform command: %s'), $command));
+		} else {
+			stream_set_blocking( $stream, true );
 			$time_start = time();
-            $data = "";
-			while( true ) {
-			    if( (time()-$time_start) > $this->timeout ){
+			$data = '';
+			while ( true ) {
+			    if( (time()-$time_start) > $this->timeout ) {
 			    	$this->errors->add('command', sprintf(__('Connection to the server has timeout after %s seconds.'), $this->timeout));
 			        break;
 			    }
-	            while( $buf = fread( $stream, strlen($stream) ) ){
-	                $data .= $buf;
-	            }
+				while( $buf = fread( $stream, strlen($stream) ) )
+					$data .= $buf;
 			}
             fclose($stream);
-            if (($returnbool) && ($data)) {
+            if ( $returnbool && $data ) {
             	$this->debug("Data: " . print_r($data, true) . " Returning: True");
             	return true;
-            } elseif (($returnbool) && (!$data)) {
+            } elseif ( $returnbool && ! $data ) {
             	$this->debug("Data: " . print_r($data, true) . " Returning: False");
             	return false;
             } else {
@@ -134,25 +143,17 @@
 	}
 
 	function setDefaultPermissions($perm) {
-		$this->permission = $perm;
+		if ( $perm )
+			$this->permission = $perm;
 	}
 
 	function get_contents($file, $type = '', $resumepos = 0 ){
-		if( empty($type) ){
-			$extension = substr(strrchr($file, "."), 1);
-			$type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII;
-		}
-		$temp = tmpfile();
-		if ( ! $temp )
+		if ( ! $tempfile = wp_tempnam( basename($file) ) );
 			return false;
-		if( ! @ssh2_scp_recv($this->link, $temp, $file) )
+		if( ! ssh2_scp_recv($this->link, $file, $tempfile) )
 			return false;
-		fseek($temp, 0); //Skip back to the start of the file being written to
-		$contents = '';
-		while (!feof($temp)) {
-			$contents .= fread($temp, 8192);
-		}
-		fclose($temp);
+		$contents = file_get_contents($tempfile);
+		unlink($tempfile);
 		return $contents;
 	}
 	
@@ -161,32 +162,26 @@
 	}
 	
 	function put_contents($file, $contents, $type = '' ) {
-		if( empty($type) ) {
-			$extension = substr(strrchr($file, "."), 1);
-			$type = isset($this->filetypes[ $extension ]) ? $this->filetypes[ $extension ] : FTP_ASCII;
-		}
-		$temp = tmpfile();
+		$tempfile = wp_tempnam( basename($file) );
+		$temp = fopen($tempfile, 'w');
 		if ( ! $temp )
 			return false;
 		fwrite($temp, $contents);
-		fseek($temp, 0); //Skip back to the start of the file being written to
-		$ret = @ssh2_scp_send($this->link, $file, $temp, $type);
 		fclose($temp);
+		$ret = ssh2_scp_send($this->link, $tempfile, $file, $this->permission);
+		unlink($tempfile);
 		return $ret;
 	}
 	
 	function cwd() {
-		$cwd = $this->run_command($this->link, "pwd");
+		$cwd = $this->run_command($this->link, 'pwd');
 		if( $cwd )
 			$cwd = trailingslashit($cwd);
 		return $cwd;
 	}
 	
 	function chdir($dir) {
-		if ($this->run_command($this->link, "cd " . $dir, true)) {
-			return true;
-		}
-		return false;
+		return ( $this->run_command($this->link, 'cd ' . $dir, true) );
 	}
 	
 	function chgrp($file, $group, $recursive = false ) {
@@ -243,16 +238,17 @@
 		return @ssh2_sftp_rename($this->link, $source, $destination);
 	}
 
-	function delete($file, $recursive=false) {
+	function delete($file, $recursive = false) {
+		//Note: Inverse boolean here, Empty string("false") returned on true,string error on failure ("true")
 		if ( $this->is_file($file) )
-			return @ssh2_sftp_unlink($this->link, $file);
+			return ! $this->run_command($this->link, 'rm ' . $file, true);
 		if ( !$recursive )
-			return @ssh2_sftp_rmdir($this->link, $file);
+			 return ! $this->run_command($this->link, 'rmdir ' . $file);
 		$filelist = $this->dirlist($file);
 		foreach ((array) $filelist as $filename => $fileinfo) {
 			$this->delete($file . '/' . $filename, $recursive);
 		}
-		return @ssh2_sftp_rmdir($this->link, $file);
+		return ! $this->run_command($this->link, 'rmdir ' . $file, true);
 	}
 
 	function exists($file) {
@@ -270,8 +266,7 @@
 		$cwd = $this->cwd();
 		$result = $this->run_command($this->link, sprintf('cd %s', $path), true);
 		if( $result && $path == $this->cwd() || $this->cwd() != $cwd ) {
-			// @todo: use ssh2_exec
-			@ftp_chdir($this->link, $cwd);
+			$this->chdir($cwd);
 			return true;
 		}
 		return false;
@@ -306,7 +301,7 @@
 	}
 	
 	function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
-		if( !@ssh2_sftp_mkdir($this->link, $path) )
+		if( $this->run_command($this->link, 'mkdir ' . $path, true) ) //true on failure
 			return false;
 		if( $chmod )
 			$this->chmod($path, $chmod);
@@ -448,4 +443,4 @@
 	}
 }
 
-?>
\ No newline at end of file
+?>
Index: wp-admin/includes/file.php
===================================================================
--- wp-admin/includes/file.php	(revision 8812)
+++ wp-admin/includes/file.php	(working copy)
@@ -480,10 +480,7 @@
 		unlink($temp_file);
 	}
 
-	if ( isset($args['connection_type']) && 'ssh' == $args['connection_type'] ) {
-		$method = 'SSH2';
-		return apply_filters('filesystem_method', $method);
-	}
+	if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') ) $method = 'ssh2';
 
 	if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
 	if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
