Some changes to allow commection with rsa keys authentication#6
Some changes to allow commection with rsa keys authentication#6AdriwanKenoby wants to merge 3 commits intosteevanb:masterfrom
Conversation
…recated extend Exception - handle error on ssh error command
| @@ -1,127 +0,0 @@ | |||
| <?php | |||
There was a problem hiding this comment.
Do not move this file from Entity to Model. Model is usefull when you need to extend it, but in this case, it's a BC and we don't need this feature
There was a problem hiding this comment.
What does mean "BC" acronym ? I think it is not an entity as an entity is persisted in DB then I have moved it to Model.
| @@ -1,28 +0,0 @@ | |||
| <?php | |||
There was a problem hiding this comment.
I want to keep this class: if i need to throw an exception who is not a ConnectionException, i will use this one
There was a problem hiding this comment.
Maybe better to create an Interface Exception
| /** | ||
| * Service for SSH2 connections | ||
| */ | ||
| class ConnectionFactory |
There was a problem hiding this comment.
Pattern Factory is a good one, but when there is just 2 lines of code, not sure it's usefull to create a service just for it.
There was a problem hiding this comment.
You did the same, I just move the Service\Connection.php class to Factory\ConnectionFactory.php
| $this->state = self::STATE_INVALID_ADDRESS; | ||
| } else { | ||
| $auth = @ssh2_auth_password($this->connection, $profile->getLogin(), $profile->getPassword()); | ||
| $auth = @ssh2_auth_pubkey_file($this->connection, $profile->getLogin(), $profile->getRsaPubKey(), $profile->getRsaPemKey(), $profile->getPassphrase()); |
There was a problem hiding this comment.
Maybe do it only when a RsaPubKey is specified, instead of try to connect with an empty Rsa, then connect without Rsa ?
| * @return string | ||
| * @param $command | ||
| * @return bool|string | ||
| * @throws ConnectionException |
There was a problem hiding this comment.
i don't add this PHPDoc, always wrong :)
| * @param string $separator Separator | ||
| * @param mixed $default Default value if $index is not found | ||
| * @return string | ||
| * @throws ConnectionException |
| * | ||
| * @param type $command | ||
| * @return array | ||
| * @throws ConnectionException |
| * @param int $index Index of the line to return | ||
| * @param string $default Default value | ||
| * @return string | ||
| * @throws ConnectionException |
| * | ||
| * @return string | ||
| */ | ||
| public function getAddress() : string |
There was a problem hiding this comment.
this lib is for PHP 5, so we can't use PHP 7 syntax :(
| # only if XX-ssh2.ini doesn't exists in /etc/php5/cli/conf.d/ | ||
| cp /etc/php5/conf.d/ssh2.ini /etc/php5/cli/conf.d/ | ||
| service apache2 restart | ||
| apt-get install libssh2-1 |
There was a problem hiding this comment.
Ok to add this documentation, but keep old one : we need it on some servers
|
I will work on it and I would provide some phpUnit test too maybe a .travis.yml |
Hi @steevanb,
I have made some changes