Ticket #8210: 8210-ssh-keys-test.diff
| File 8210-ssh-keys-test.diff, 4.3 KB (added by , 17 years ago) |
|---|
-
wp-admin/includes/class-wp-filesystem-ssh2.php
84 84 $this->wp_base = $opt['base']; 85 85 86 86 // Check if the options provided are OK. 87 if ( empty ($opt['username']) ) 88 $this->errors->add('empty_username', __('SSH2 username is required')); 89 else 90 $this->options['username'] = $opt['username']; 91 92 if ( ( !empty ($opt['public_key']) ) && ( !empty ($opt['private_key']) ) ) { 87 if ( !empty ($opt['public_key']) && !empty ($opt['private_key']) ) { 93 88 $this->options['public_key'] = $opt['public_key']; 94 89 $this->options['private_key'] = $opt['private_key']; 95 90 96 $this->options['hostkey'] = array( "hostkey" => "ssh-rsa");91 $this->options['hostkey'] = array('hostkey' => 'ssh-rsa'); 97 92 98 93 $this->keys = true; 94 } elseif ( empty ($opt['username']) ) { 95 $this->errors->add('empty_username', __('SSH2 username is required')); 99 96 } 100 97 98 if ( !empty($opt['username']) ) 99 $this->options['username'] = $opt['username']; 101 100 102 101 if ( empty ($opt['password']) ) { 103 102 if ( !$this->keys ) // password can be blank if we are using keys … … 114 113 if ( ! $this->keys ) { 115 114 $this->link = @ssh2_connect($this->options['hostname'], $this->options['port']); 116 115 } else { 117 $this->link = @ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']);116 $this->link = ssh2_connect($this->options['hostname'], $this->options['port'], $this->options['hostkey']); 118 117 } 119 118 120 119 if ( ! $this->link ) { … … 128 127 return false; 129 128 } 130 129 } else { 131 if ( ! @ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ) ) {130 if ( ! ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'] ) ) { //, $this->options['password'] 132 131 $this->errors->add('auth', sprintf(__('Public and Private keys incorrent for %s'), $this->options['username'])); 133 132 return false; 134 133 } -
wp-admin/includes/file.php
681 681 $credentials['connection_type'] = 'ftps'; 682 682 else if ( !isset($credentials['connection_type']) || (isset($_POST['connection_type']) && 'ftp' == $_POST['connection_type']) ) 683 683 $credentials['connection_type'] = 'ftp'; 684 685 if ( ! $error && !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) { 684 var_Dump($credentials); 685 if ( ! $error && 686 ( 687 ( !empty($credentials['password']) && !empty($credentials['username']) && !empty($credentials['hostname']) ) || 688 ( 'ssh' == $credentials['connection_type'] && !empty($credentials['public_key']) && !empty($credentials['private_key']) ) 689 ) ) { 686 690 $stored_credentials = $credentials; 687 691 if ( !empty($stored_credentials['port']) ) //save port as part of hostname to simplify above code. 688 692 $stored_credentials['hostname'] .= ':' . $stored_credentials['port']; … … 743 747 <label for="public_key"><?php _e('Public Key:') ?></label ><br /> 744 748 <label for="private_key"><?php _e('Private Key:') ?></label> 745 749 </div></th> 746 <td><br /><input name="public_key" type="text" id="public_key" value=" "<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value=""<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />750 <td><br /><input name="public_key" type="text" id="public_key" value="<?php echo attribute_escape($public_key) ?>"<?php if( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo attribute_escape($private_key) ?>"<?php if( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" /> 747 751 <div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td> 748 752 </tr> 749 753