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);
}
Aggregations