Altax\Module\Server\ServerModule::nodesFromSSHConfigHosts PHP Method

nodesFromSSHConfigHosts() public method

public nodesFromSSHConfigHosts ( $paths = [] )
    public function nodesFromSSHConfigHosts($paths = array())
    {
        $configPaths = array();
        if (is_string($paths)) {
            $configPaths[] = $paths;
        } else {
            $configPaths = $paths;
        }
        if (sizeof($configPaths) < 1) {
            $configPaths = array("/etc/ssh_config", "/etc/ssh/ssh_config", Env::get("homedir") . "/.ssh/config");
        }
        $nodesOptions = SSHConfig::parseToNodeOptionsFromFiles($configPaths);
        foreach ($nodesOptions as $key => $option) {
            $this->node($key, $option);
        }
    }

Usage Example

Example #1
0
 public function testNodesFromSSHConfigHosts3()
 {
     $module = new ServerModule($this->container);
     $module->nodesFromSSHConfigHosts(array(__DIR__ . "/../../Util/SSHConfigTest/ssh_config", __DIR__ . "/../../Util/SSHConfigTest/ssh_config2"));
     $this->assertSame("test-server2", $module->getNode("test-server2")->getName());
     $this->assertSame("test-server3", $module->getNode("test-server3")->getName());
 }