Index: wp-admin/includes/class-wp-filesystem-ssh2.php
===================================================================
--- wp-admin/includes/class-wp-filesystem-ssh2.php	(revision 9672)
+++ wp-admin/includes/class-wp-filesystem-ssh2.php	(working copy)
@@ -141,14 +141,14 @@
 
 	function run_command($link, $command, $returnbool = false) {
 		$this->debug("run_command();");
-		if(!($stream = @ssh2_exec( $link, $command . "; echo \"__COMMAND_FINISHED__\";"))) {
+		if(!($stream = @ssh2_exec( $link, $command . '; echo "__COMMAND_FINISHED__";'))) {
 			$this->errors->add('command', sprintf(__('Unable to perform command: %s'), $command));
 		} else {
 			stream_set_blocking( $stream, true );
 			$time_start = time();
 			$data = null;
 			while( true ) {
-				if (strpos($data,"__COMMAND_FINISHED__") !== false){
+				if (strpos($data,'__COMMAND_FINISHED__') !== false){
 					break;	//	the command has finshed!
 				}
 				if( (time()-$time_start) > $this->timeout ){
@@ -189,6 +189,18 @@
 
 	function get_contents($file, $type = '', $resumepos = 0 ) {
 		$this->debug("get_contents();");
+		
+		if ( true ) {
+			$handle = @fopen('ssh2.sftp://' . $this->link . $file, 'rb');
+			if ( ! $handle )
+				return false;
+			$content = '';
+			while ( ! @feof($handle) )
+				$contents .= fread($handle, 8092);
+			fclose($handle);
+			return $contents;
+		}
+
 		$tempfile = wp_tempnam( $file );
 		if ( ! $tempfile )
 			return false;
@@ -206,6 +218,15 @@
 
 	function put_contents($file, $contents, $type = '' ) {
 		$this->debug("put_contents($file);");
+		
+		if ( true ) {
+			$handle = @fopen('ssh2.sftp://' . $this->link . $file, 'w');
+			if ( ! $handle || ! @fwrite($handle, $contents) )
+				return false;
+			fclose($handle);
+			return true;
+		}
+		
 		$tempfile = wp_tempnam( $file );
 		$temp = fopen($tempfile, 'w');
 		if ( ! $temp )
@@ -235,8 +256,8 @@
 		if ( ! $this->exists($file) )
 			return false;
 		if ( ! $recursive || ! $this->is_dir($file) )
-			return $this->run_command($this->link, sprintf('chgrp %o %s', $mode, $file), true);
-		return $this->run_command($this->link, sprintf('chgrp -R %o %s', $mode, $file), true);
+			return $this->run_command($this->link, sprintf('chgrp %o "%s"', $mode, $file), true);
+		return $this->run_command($this->link, sprintf('chgrp -R %o "%s"', $mode, $file), true);
 	}
 
 	function chmod($file, $mode = false, $recursive = false) {
@@ -248,8 +269,8 @@
 		if ( ! $this->exists($file) )
 			return false;
 		if ( ! $recursive || ! $this->is_dir($file) )
-			return $this->run_command($this->link, sprintf('chmod %o %s', $mode, $file), true);
-		return $this->run_command($this->link, sprintf('chmod -R %o %s', $mode, $file), true);
+			return $this->run_command($this->link, sprintf('chmod %o "%s"', $mode, $file), true);
+		return $this->run_command($this->link, sprintf('chmod -R %o "%s"', $mode, $file), true);
 	}
 
 	function chown($file, $owner, $recursive = false ) {
@@ -257,8 +278,8 @@
 		if ( ! $this->exists($file) )
 			return false;
 		if ( ! $recursive || ! $this->is_dir($file) )
-			return $this->run_command($this->link, sprintf('chown %o %s', $mode, $file), true);
-		return $this->run_command($this->link, sprintf('chown -R %o %s', $mode, $file), true);
+			return $this->run_command($this->link, sprintf('chown %o "%s"', $mode, $file), true);
+		return $this->run_command($this->link, sprintf('chown -R %o "%s"', $mode, $file), true);
 	}
 
 	function owner($file) {
@@ -311,14 +332,14 @@
 
 	function exists($file) {
 		$this->debug("exists();");
-		$list = $this->run_command($this->link, sprintf('ls -lad %s', $file));
+		$list = $this->run_command($this->link, sprintf('ls -lad "%s"', $file));
 		return (bool) $list;
 	}
 
 	function is_file($file) {
 		$this->debug("is_file();");
 		//DO NOT RELY ON dirlist()!
-		$list = $this->run_command($this->link, sprintf('ls -lad %s', $file));
+		$list = $this->run_command($this->link, sprintf('ls -lad "%s"', $file));
 		$list = $this->parselisting($list);
 		if ( ! $list )
 			return false;
@@ -329,7 +350,7 @@
 	function is_dir($path) {
 		$this->debug("is_dir();");
 		//DO NOT RELY ON dirlist()!
-		$list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad %s', untrailingslashit($path))));
+		$list = $this->parselisting($this->run_command($this->link, sprintf('ls -lad "%s"', untrailingslashit($path))));
 		if ( ! $list )
 			return false;
 		else
@@ -449,7 +470,7 @@
 			$limitFile = false;
 		}
 
-		$list = $this->run_command($this->link, sprintf('ls -la %s', $path));
+		$list = $this->run_command($this->link, sprintf('ls -la "%s"', $path));
 
 		if ( $list === false )
 			return false;
