@Given("^I open a ssh connection to '(.+?)'( in port '(.+?)')? with user '(.+?)'( and password '(.+?)')?( using pem file '(.+?)')?$")
    public void openSSHConnection(String remoteHost, String tmp, String remotePort, String user, String foo, String password, String bar, String pemFile) throws Exception {
        if ((pemFile == null) || (pemFile.equals("none"))) {
            if (password == null) {
                throw new Exception("You have to provide a password or a pem file to be used for connection");
            }
            commonspec.setRemoteSSHConnection(new RemoteSSHConnection(user, password, remoteHost, remotePort, null));
            commonspec.getLogger().debug("Opening ssh connection with password: { " + password + "}", commonspec.getRemoteSSHConnection());
        } else {
            File pem = new File(pemFile);
            if (!pem.exists()) {
                throw new Exception("Pem file: " + pemFile + " does not exist");
            }
            commonspec.setRemoteSSHConnection(new RemoteSSHConnection(user, null, remoteHost, remotePort, pemFile));
            commonspec.getLogger().debug("Opening ssh connection with pemFile: {}", commonspec.getRemoteSSHConnection());
        }
    }
@ Given ( "^I open a ssh connection to '(.+?)'( in port '(.+?)')? with user '(.+?)'( and password '(.+?)')?( using pem file '(.+?)')?$" ) public void openSSHConnection ( String remoteHost , String tmp , String remotePort , String user , String foo , String password , String bar , String pemFile ) throws Exception { if ( ( pemFile == null ) || ( pemFile . equals ( "none" ) ) ) { if ( password == null ) { throw new Exception ( "You have to provide a password or a pem file to be used for connection" ) ; } commonspec . setRemoteSSHConnection ( new RemoteSSHConnection ( user , password , remoteHost , remotePort , null ) ) ; commonspec . getLogger ( ) . debug ( "Opening ssh connection with password: { " + password + "}" , commonspec . getRemoteSSHConnection ( ) ) ; } else { File pem = new File ( pemFile ) ; if ( ! pem . exists ( ) ) { throw new Exception ( "Pem file: " + pemFile + " does not exist" ) ; } commonspec . setRemoteSSHConnection ( new RemoteSSHConnection ( user , null , remoteHost , remotePort , pemFile ) ) ; commonspec . getLogger ( ) . debug ( "Opening ssh connection with pemFile: {}" , commonspec . getRemoteSSHConnection ( ) ) ; } }
Opens a ssh connection to remote host

@param remoteHost remote host
@param user       remote user
@param password   (required if pemFile null)
@param pemFile    (required if password null)
@throws Exception exception