Search in sources :

Example 1 with OpenSSHConfig

use of com.jcraft.jsch.OpenSSHConfig in project arduino-eclipse-plugin by Sloeber.

the class SSHConfigFileSetup method setup.

@Override
public Session setup(BoardPort port, JSch jSch) throws JSchException, IOException {
    String hostname = port.getBoardName().contains(".local") ? port.getBoardName() : port.getBoardName() + ".local";
    File sshFolder = new File(System.getProperty("user.home"), ".ssh");
    File sshConfig = new File(sshFolder, "config");
    if (!sshFolder.exists() || !sshConfig.exists()) {
        if (nextChainRing != null) {
            return nextChainRing.setup(port, jSch);
        }
        throw new JSchException("Unable to find a way to connect");
    }
    OpenSSHConfig configRepository = OpenSSHConfig.parseFile(sshConfig.getAbsolutePath());
    jSch.setConfigRepository(new OpenSSHConfigWrapper(configRepository, hostname));
    return jSch.getSession(hostname);
}
Also used : JSchException(com.jcraft.jsch.JSchException) OpenSSHConfig(com.jcraft.jsch.OpenSSHConfig) File(java.io.File)

Aggregations

JSchException (com.jcraft.jsch.JSchException)1 OpenSSHConfig (com.jcraft.jsch.OpenSSHConfig)1 File (java.io.File)1