Deployer\Server\Remote\SshExtension::connect PHP Method

connect() public method

public connect ( )
    public function connect()
    {
        $serverConfig = $this->getConfiguration();
        $configuration = new Ssh\Configuration($serverConfig->getHost(), $serverConfig->getPort());
        switch ($serverConfig->getAuthenticationMethod()) {
            case Configuration::AUTH_BY_PASSWORD:
                $authentication = new Ssh\Authentication\Password($serverConfig->getUser(), $serverConfig->getPassword());
                break;
            case Configuration::AUTH_BY_CONFIG:
                $configuration = new Ssh\SshConfigFileConfiguration($serverConfig->getConfigFile(), $serverConfig->getHost(), $serverConfig->getPort());
                $authentication = $configuration->getAuthentication($serverConfig->getPassword(), $serverConfig->getUser());
                break;
            case Configuration::AUTH_BY_IDENTITY_FILE:
                $authentication = new Ssh\Authentication\PublicKeyFile($serverConfig->getUser(), $serverConfig->getPublicKey(), $serverConfig->getPrivateKey(), $serverConfig->getPassPhrase());
                break;
            case Configuration::AUTH_BY_PEM_FILE:
                throw new \RuntimeException('If you want to use pem file, switch to using PhpSecLib.');
            case Configuration::AUTH_BY_AGENT:
                $authentication = new \Ssh\Authentication\Agent($serverConfig->getUser());
                break;
            default:
                throw new \RuntimeException('You need to specify authentication method.');
        }
        $this->session = new Ssh\Session($configuration, $authentication);
    }