@Service(name="SSHLauncher") @PerLookup public class SSHLauncher extends Object
| Constructor and Description |
|---|
SSHLauncher() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkConnection()
Check if we can authenticate using public key auth
|
boolean |
checkPasswordAuth()
Check if we can connect using password auth
|
String |
expandPasswordAlias(String alias) |
com.trilead.ssh2.SCPClient |
getSCPClient() |
SFTPClient |
getSFTPClient() |
void |
init(Logger logger) |
void |
init(Node node,
Logger logger)
Initialize the SSHLauncher use a Node config object
|
void |
init(String userName,
String host,
int port,
String password,
char[] privateKey,
Logger logger)
Initialize the SSHLauncher using a private key
|
void |
init(String userName,
String host,
int port,
String password,
String keyFile,
String keyPassPhrase,
Logger logger)
Initialize the SSHLauncher using a private key file
|
boolean |
isPasswordAlias(String alias) |
void |
pingConnection() |
int |
runCommand(List<String> command,
OutputStream os) |
int |
runCommand(List<String> command,
OutputStream os,
List<String> stdinLines)
Executes a command on the remote system via ssh, optionally sending
lines of data to the remote process's System.in.
|
int |
runCommand(String command,
OutputStream os)
WARNING! This method does not handle paths with spaces in them.
|
int |
runCommand(String command,
OutputStream os,
List<String> stdinLines)
Executes a command on the remote system via ssh, optionally sending
lines of data to the remote process's System.in.
|
int |
runCommandAsIs(List<String> command,
OutputStream os,
List<String> stdinLines)
Executes a command on the remote system via ssh without normalizing
the command line
|
int |
runCommandAsIs(List<String> command,
OutputStream os,
List<String> stdinLines,
String[] env)
Executes a command on the remote system via ssh without normalizing
the command line
|
void |
setupKey(String node,
String pubKeyFile,
boolean generateKey,
String passwd)
Setting up the key involves the following steps:
-If a key exists and we can connect using the key, do nothing.
|
static byte[] |
toByteArray(InputStream input) |
String |
toString() |
void |
validate(String host,
int port,
String userName,
String password,
String keyFile,
String keyPassPhrase,
String installDir,
Logger logger) |
void |
validate(String host,
int port,
String userName,
String password,
String keyFile,
String keyPassPhrase,
String installDir,
String landmarkPath,
Logger logger) |
public void init(Logger logger)
public void init(Node node, Logger logger)
node - logger - public void init(String userName, String host, int port, String password, char[] privateKey, Logger logger)
userName - host - port - password - privateKey - logger - public void init(String userName, String host, int port, String password, String keyFile, String keyPassPhrase, Logger logger)
userName - host - port - password - keyFile - keyPassPhrase - logger - public int runCommand(List<String> command, OutputStream os, List<String> stdinLines) throws IOException, InterruptedException
command - the command to execute in the form of an argv style listos - stream to receive the output from the commandstdinLines - optional data to be sent to the process's System.in
stream; null if no input should be sentIOExceptionInterruptedExceptionpublic int runCommand(List<String> command, OutputStream os) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic int runCommand(String command, OutputStream os) throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic int runCommand(String command, OutputStream os, List<String> stdinLines) throws IOException, InterruptedException
command - the command to executeos - stream to receive the output from the commandstdinLines - optional data to be sent to the process's System.in stream; null if no input should be sentIOExceptionInterruptedExceptionpublic int runCommandAsIs(List<String> command, OutputStream os, List<String> stdinLines) throws IOException, InterruptedException
command - the command to executeos - stream to receive the output from the commandstdinLines - optional data to be sent to the process's System.in
stream; null if no input should be sentIOExceptionInterruptedExceptionpublic int runCommandAsIs(List<String> command, OutputStream os, List<String> stdinLines, String[] env) throws IOException, InterruptedException
command - the command to executeos - stream to receive the output from the commandstdinLines - optional data to be sent to the process's System.in
stream; null if no input should be sentenv - list of environment variables to set before executing the command. each array cell is like varname=varvalue. This only supports on csh, t-csh and bashIOExceptionInterruptedExceptionpublic void pingConnection()
throws IOException,
InterruptedException
IOExceptionInterruptedExceptionpublic void validate(String host, int port, String userName, String password, String keyFile, String keyPassPhrase, String installDir, String landmarkPath, Logger logger) throws IOException
IOExceptionpublic void validate(String host, int port, String userName, String password, String keyFile, String keyPassPhrase, String installDir, Logger logger) throws IOException
IOExceptionpublic SFTPClient getSFTPClient() throws IOException
IOExceptionpublic com.trilead.ssh2.SCPClient getSCPClient()
throws IOException
IOExceptionpublic boolean isPasswordAlias(String alias)
public void setupKey(String node, String pubKeyFile, boolean generateKey, String passwd) throws IOException, InterruptedException
node - - remote hostpubKeyFile - - .pub filegenerateKey - - flag to indicate if key needs to be generated or notpasswd - - ssh user passwordIOExceptionInterruptedExceptionpublic static byte[] toByteArray(InputStream input) throws IOException
IOExceptionpublic boolean checkConnection()
public boolean checkPasswordAuth()
Copyright © 2017. All rights reserved.