public void initConnection()

in controller/src/main/java/org/apache/airavata/mft/controller/spawner/SSHProvider.java [51:97]


    public void initConnection(String hostName, int port, String keyPath, String user) throws IOException {
        this.hostName = hostName;
        DefaultConfig defaultConfig = new DefaultConfig();
        defaultConfig.setKeepAliveProvider(KeepAliveProvider.KEEP_ALIVE);

        client = new SSHClient(defaultConfig);
        client.addHostKeyVerifier(new HostKeyVerifier() {
            @Override
            public boolean verify(String s, int i, PublicKey publicKey) {
                return true;
            }

            @Override
            public List<String> findExistingAlgorithms(String s, int i) {
                return null;
            }
        });

        KeyProvider keyProvider = client.loadKeys(keyPath);

        final List<AuthMethod> am = new LinkedList<>();
        am.add(new AuthPublickey(keyProvider));

        am.add(new AuthKeyboardInteractive(new ChallengeResponseProvider() {
            @Override
            public List<String> getSubmethods() {
                return new ArrayList<>();
            }

            @Override
            public void init(Resource resource, String name, String instruction) {
            }

            @Override
            public char[] getResponse(String prompt, boolean echo) {
                return new char[0];
            }

            @Override
            public boolean shouldRetry() {
                return false;
            }
        }));

        client.connect(hostName, port);
        client.auth(user, am);
    }