using SshConfigFileConfiguration if the configuration has not defined "identityfile"
I suggets use the same behavior the SSH if i have a host configurate in ~/.ssh/config file like this
Host mytest Hostname ssh.mytest.com User testing Port 5022
the method SshConfigFileConfiguration::getAuthentication must check first if a ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub exist and use at last Authentication\None
modifing the method SshConfigFileConfiguration::getConfigForHost like this
class SshConfigFileConfiguration extends Configuration
{
const DEFAULT_FILE = '~/.ssh/id_rsa';
// ...
public function getConfigForHost($host)
{
$matches = array();
foreach ($this->configs as $config) {
if (fnmatch($config['host'], $host)) {
$matches[] = $config;
}
}
if (count($matches) == 0) {
throw new RuntimeException("Unable to find configuration for host '{$host}'");
}
usort($matches, function ($a, $b) {
return strlen($a['host']) > strlen($b['host']);
});
$result = array();
foreach ($matches as $match) {
$result = array_merge($result, $match);
}
unset($result['host']);
if (isset($result['identityfile'])) {
$result['identityfile'] = $this->processPath($result['identityfile']);
} else if (file_exists($file = $this->processPath(self::DEFAULT_FILE))) {
$result['identityfile'] = $file;
}
return $result;
}
}
solves the problem quickly
It would be awesome if you could do a PR.
@Herzult i made it, can you merge please, i have other PR to send you ;)
@Herzult would really appreciate this related PR to be merged, need the feature ;)