Package adams.core.net
Class JSchUtils
- java.lang.Object
-
- adams.core.net.JSchUtils
-
public class JSchUtils extends Object
Helper class for SSH connections usingJSch.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description JSchUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidconfigureStrictHostKeyChecking(com.jcraft.jsch.Session session, boolean strict)Configures the session for strict host key checks.static voidconfigureX11(com.jcraft.jsch.Session session, String host, int port)Configures the session for X11.static TechnicalInformationgetTechnicalInformation()Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.static com.jcraft.jsch.JSchnewJsch(File knownHosts)Instantiates a new JSch object.static com.jcraft.jsch.SessionnewSession(com.jcraft.jsch.JSch jsch, String user, File privateKey, String password, String host, int port)Creates a new session using public-key-based authentication.static com.jcraft.jsch.SessionnewSession(com.jcraft.jsch.JSch jsch, String user, String password, String host, int port)Creates a new session using credentials-based authentication.
-
-
-
Method Detail
-
newJsch
public static com.jcraft.jsch.JSch newJsch(File knownHosts) throws Exception
Instantiates a new JSch object.- Parameters:
knownHosts- the file pointing to the known hosts config file, can be null- Returns:
- the object
- Throws:
Exception- if known hosts file fails
-
newSession
public static com.jcraft.jsch.Session newSession(com.jcraft.jsch.JSch jsch, String user, String password, String host, int port) throws ExceptionCreates a new session using credentials-based authentication.- Parameters:
jsch- the JSch contextuser- the userpassword- the password to usehost- the host to connect toport- the port to connect to- Returns:
- the session
- Throws:
Exception- if creation of session fails
-
newSession
public static com.jcraft.jsch.Session newSession(com.jcraft.jsch.JSch jsch, String user, File privateKey, String password, String host, int port) throws ExceptionCreates a new session using public-key-based authentication.- Parameters:
jsch- the JSch contextuser- the userprivateKey- the private key filepassword- the password to use to open the private key file, empty or null if not necessaryhost- the host to connect toport- the port to connect to- Returns:
- the session
- Throws:
Exception- if creation of session fails
-
configureStrictHostKeyChecking
public static void configureStrictHostKeyChecking(com.jcraft.jsch.Session session, boolean strict)Configures the session for strict host key checks.- Parameters:
session- the session to configurestrict- true if to perform strict checks
-
configureX11
public static void configureX11(com.jcraft.jsch.Session session, String host, int port)Configures the session for X11.- Parameters:
session- the session to configurehost- the X11 hostport- the X11 port
-
getTechnicalInformation
public static TechnicalInformation getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.- Returns:
- the technical information about this class
-
-