Package com.github.fracpete.rsync4j
Class Ssh
- java.lang.Object
-
- com.github.fracpete.rsync4j.core.AbstractBinary
-
- com.github.fracpete.rsync4j.core.AbstractBinaryWithTimeout
-
- com.github.fracpete.rsync4j.Ssh
-
public class Ssh extends AbstractBinaryWithTimeout
Wrapper for the ssh binary.
NB: No interactive shell possible.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanallowRemoteConnectprotected booleanbackgroundprotected java.lang.StringbindAddressprotected java.lang.StringcipherSpecprotected java.lang.Stringcommandprotected booleancompressionprotected java.lang.StringconfigFileprotected java.lang.StringcontrolCommandprotected java.lang.StringcontrolSocketprotected java.lang.StringdynamicBindAddressprotected java.lang.StringescapeCharprotected java.lang.BooleanforwardAgentprotected java.lang.StringforwardToprotected java.lang.StringforwardTunnelprotected booleanfromNullprotected java.lang.Booleangssapiprotected java.lang.Stringhostnameprotected java.lang.StringidentifyFileprotected booleanipv4protected booleanipv6protected java.lang.Stringlocalprotected java.lang.StringlogFileprotected java.lang.StringloginNameprotected java.lang.StringmacSpecprotected booleanmasterModeprotected booleannoRemoteExecuteprotected java.util.List<java.lang.String>optionprotected java.lang.Stringpkcs11protected intportprotected booleanprintConfigprotected java.lang.StringqueryOptionprotected booleanquietprotected java.lang.Stringremoteprotected SshPasssshPassprotected booleansubsystemprotected booleansyslogprotected java.lang.Booleanterminalprotected booleantrustedX11protected intverboseprotected booleanversionprotected booleanversion1protected booleanversion2protected java.lang.Booleanx11-
Fields inherited from class com.github.fracpete.rsync4j.core.AbstractBinaryWithTimeout
max_time
-
Fields inherited from class com.github.fracpete.rsync4j.core.AbstractBinary
logger, outputCommandline, outputSingleCommandline
-
-
Constructor Summary
Constructors Constructor Description Ssh()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SshallowRemoteConnect(boolean value)ssh option: -gSshbackground(boolean value)ssh option: -fSshbindAddress(java.lang.String value)ssh option: -bSshcipherSpec(java.lang.String value)ssh option: -cSshcommand(java.lang.String value)java.util.List<java.lang.String>commandLineArgs()Assembles the full command-line arguments.Sshcompression(boolean value)ssh option: -CSshconfigFile(java.lang.String value)ssh option: -FSshcontrolCommand(java.lang.String value)ssh option: -OSshcontrolSocket(java.lang.String value)ssh option: -Sprotected java.lang.Stringdescription()Returns a short description for the binary.SshdynamicBindAddress(java.lang.String value)ssh option: -DSshescapeChar(java.lang.String value)ssh option: -eSshforwardAgent(java.lang.Boolean value)Use null to set it to user/system default.SshforwardTo(java.lang.String value)ssh option: -WSshforwardTunnel(java.lang.String value)ssh option: -wSshfromNull(boolean value)ssh option: -nbooleangetAllowRemoteConnect()ssh option: -gbooleangetBackground()ssh option: -fjava.lang.StringgetBindAddress()ssh option: -bjava.lang.StringgetCipherSpec()ssh option: -cjava.lang.StringgetCommand()booleangetCompression()ssh option: -Cjava.lang.StringgetConfigFile()ssh option: -Fjava.lang.StringgetControlCommand()ssh option: -Ojava.lang.StringgetControlSocket()ssh option: -Sjava.lang.StringgetDynamicBindAddress()ssh option: -Djava.lang.StringgetEscapeChar()ssh option: -ejava.lang.BooleangetForwardAgent()ssh option: -A (true)/-a (false)java.lang.StringgetForwardTo()ssh option: -Wjava.lang.StringgetForwardTunnel()ssh option: -wbooleangetFromNull()ssh option: -njava.lang.BooleangetGssapi()ssh option: -K (true)/-k (false)java.lang.StringgetHostname()java.lang.StringgetIdentifyFile()ssh option: -ibooleangetIpv4()ssh option: -4booleangetIpv6()ssh option: -6java.lang.StringgetLocal()ssh option: -Ljava.lang.StringgetLogFile()ssh option: -Ejava.lang.StringgetLoginName()ssh option: -ljava.lang.StringgetMacSpec()ssh option: -mbooleangetMasterMode()ssh option: -MbooleangetNoRemoteExecute()ssh option: -Njava.util.List<java.lang.String>getOption()ssh option: -oprotected net.sourceforge.argparse4j.inf.ArgumentParsergetParser()Configures and returns the commandline parser.java.lang.StringgetPkcs11()ssh option: -IintgetPort()ssh option: -pbooleangetPrintConfig()ssh option: -Gjava.lang.StringgetQueryOption()ssh option: -QbooleangetQuiet()ssh option: -qjava.lang.StringgetRemote()ssh option: -RSshPassgetSshPass()Returns the current sshpass instance in use.booleangetSubsystem()ssh option: -sbooleangetSyslog()ssh option: -yjava.lang.BooleangetTerminal()ssh option: -t (true)/-T (false)booleangetTrustedX11()ssh option: -YintgetVerbose()ssh option: -v/-vv/-vvvbooleangetVersion()ssh option: -vbooleangetVersion1()ssh option: -2booleangetVersion2()ssh option: -2java.lang.BooleangetX11()ssh option: -XSshgssapi(java.lang.Boolean value)Use null to set it to user/system default.Sshhostname(java.lang.String value)SshidentifyFile(java.lang.String value)ssh option: -iSshipv4(boolean value)ssh option: -4Sshipv6(boolean value)ssh option: -6Sshlocal(java.lang.String value)ssh option: -LSshlogFile(java.lang.String value)ssh option: -ESshloginName(java.lang.String value)ssh option: -lSshmacSpec(java.lang.String value)ssh option: -mstatic voidmain(java.lang.String[] args)For running from the command-line.SshmasterMode(boolean value)ssh option: -MSshnoRemoteExecute(boolean value)ssh option: -NSshoption(java.lang.String... value)ssh option: -oSshoption(java.util.List<java.lang.String> value)ssh option: -ojava.util.List<java.lang.String>options()Assembles the arguments for the binary.SshoutputCommandline(boolean value)Sets output commandline flag.Sshpkcs11(java.lang.String value)ssh option: -ISshport(int value)ssh option: -pSshprintConfig(boolean value)ssh option: -GSshqueryOption(java.lang.String value)ssh option: -QSshquiet(boolean value)ssh option: -qSshremote(java.lang.String value)ssh option: -Rvoidreset()Resets the members.protected booleansetOptions(net.sourceforge.argparse4j.inf.Namespace ns)Sets the parsed options.SshsshPass(SshPass value)Sets the sshpass instance to use.Sshsubsystem(boolean value)ssh option: -sSshsyslog(boolean value)ssh option: -ySshterminal(java.lang.Boolean value)Use null to set it to user/system default.SshtrustedX11(boolean value)ssh option: -YSshverbose(int value)ssh option: -v/-vv/-vvvSshversion(boolean value)ssh option: -vSshversion1(boolean value)ssh option: -1Sshversion2(boolean value)ssh option: -2Sshx11(java.lang.Boolean value)Use null to set it to user/system default.-
Methods inherited from class com.github.fracpete.rsync4j.core.AbstractBinaryWithTimeout
execute, getMaxTime, maxTime, run
-
Methods inherited from class com.github.fracpete.rsync4j.core.AbstractBinary
builder, commandLine, getOutputCommandline, getOutputSingleCommandline, outputSingleCommandline, run, setOptions, start
-
-
-
-
Field Detail
-
version1
protected boolean version1
-
version2
protected boolean version2
-
ipv4
protected boolean ipv4
-
ipv6
protected boolean ipv6
-
forwardAgent
protected java.lang.Boolean forwardAgent
-
bindAddress
protected java.lang.String bindAddress
-
compression
protected boolean compression
-
cipherSpec
protected java.lang.String cipherSpec
-
dynamicBindAddress
protected java.lang.String dynamicBindAddress
-
logFile
protected java.lang.String logFile
-
escapeChar
protected java.lang.String escapeChar
-
configFile
protected java.lang.String configFile
-
background
protected boolean background
-
printConfig
protected boolean printConfig
-
allowRemoteConnect
protected boolean allowRemoteConnect
-
pkcs11
protected java.lang.String pkcs11
-
identifyFile
protected java.lang.String identifyFile
-
gssapi
protected java.lang.Boolean gssapi
-
local
protected java.lang.String local
-
loginName
protected java.lang.String loginName
-
masterMode
protected boolean masterMode
-
macSpec
protected java.lang.String macSpec
-
noRemoteExecute
protected boolean noRemoteExecute
-
fromNull
protected boolean fromNull
-
controlCommand
protected java.lang.String controlCommand
-
option
protected java.util.List<java.lang.String> option
-
port
protected int port
-
queryOption
protected java.lang.String queryOption
-
quiet
protected boolean quiet
-
remote
protected java.lang.String remote
-
controlSocket
protected java.lang.String controlSocket
-
subsystem
protected boolean subsystem
-
terminal
protected java.lang.Boolean terminal
-
version
protected boolean version
-
verbose
protected int verbose
-
forwardTo
protected java.lang.String forwardTo
-
forwardTunnel
protected java.lang.String forwardTunnel
-
x11
protected java.lang.Boolean x11
-
trustedX11
protected boolean trustedX11
-
syslog
protected boolean syslog
-
hostname
protected java.lang.String hostname
-
command
protected java.lang.String command
-
sshPass
protected SshPass sshPass
-
-
Method Detail
-
reset
public void reset()
Resets the members.- Overrides:
resetin classAbstractBinaryWithTimeout
-
outputCommandline
public Ssh outputCommandline(boolean value)
Sets output commandline flag.- Overrides:
outputCommandlinein classAbstractBinary- Parameters:
value- true if to output commandline- Returns:
- itself
-
version1
public Ssh version1(boolean value)
ssh option: -1
-
getVersion1
public boolean getVersion1()
ssh option: -2
-
version2
public Ssh version2(boolean value)
ssh option: -2
-
getVersion2
public boolean getVersion2()
ssh option: -2
-
ipv4
public Ssh ipv4(boolean value)
ssh option: -4
-
getIpv4
public boolean getIpv4()
ssh option: -4
-
ipv6
public Ssh ipv6(boolean value)
ssh option: -6
-
getIpv6
public boolean getIpv6()
ssh option: -6
-
forwardAgent
public Ssh forwardAgent(java.lang.Boolean value)
Use null to set it to user/system default. Other true/false to turn on/off. ssh option: -A (true)/-a (false)- Parameters:
value- the value, null for default- Returns:
- itself
-
getForwardAgent
public java.lang.Boolean getForwardAgent()
ssh option: -A (true)/-a (false)
-
bindAddress
public Ssh bindAddress(java.lang.String value)
ssh option: -b
-
getBindAddress
public java.lang.String getBindAddress()
ssh option: -b
-
compression
public Ssh compression(boolean value)
ssh option: -C
-
getCompression
public boolean getCompression()
ssh option: -C
-
cipherSpec
public Ssh cipherSpec(java.lang.String value)
ssh option: -c
-
getCipherSpec
public java.lang.String getCipherSpec()
ssh option: -c
-
dynamicBindAddress
public Ssh dynamicBindAddress(java.lang.String value)
ssh option: -D
-
getDynamicBindAddress
public java.lang.String getDynamicBindAddress()
ssh option: -D
-
logFile
public Ssh logFile(java.lang.String value)
ssh option: -E
-
getLogFile
public java.lang.String getLogFile()
ssh option: -E
-
escapeChar
public Ssh escapeChar(java.lang.String value)
ssh option: -e
-
getEscapeChar
public java.lang.String getEscapeChar()
ssh option: -e
-
configFile
public Ssh configFile(java.lang.String value)
ssh option: -F
-
getConfigFile
public java.lang.String getConfigFile()
ssh option: -F
-
background
public Ssh background(boolean value)
ssh option: -f
-
getBackground
public boolean getBackground()
ssh option: -f
-
printConfig
public Ssh printConfig(boolean value)
ssh option: -G
-
getPrintConfig
public boolean getPrintConfig()
ssh option: -G
-
allowRemoteConnect
public Ssh allowRemoteConnect(boolean value)
ssh option: -g
-
getAllowRemoteConnect
public boolean getAllowRemoteConnect()
ssh option: -g
-
pkcs11
public Ssh pkcs11(java.lang.String value)
ssh option: -I
-
getPkcs11
public java.lang.String getPkcs11()
ssh option: -I
-
identifyFile
public Ssh identifyFile(java.lang.String value)
ssh option: -i
-
getIdentifyFile
public java.lang.String getIdentifyFile()
ssh option: -i
-
gssapi
public Ssh gssapi(java.lang.Boolean value)
Use null to set it to user/system default. Other true/false to turn on/off. ssh option: -K (true)/-k (false)- Parameters:
value- the value, null for default- Returns:
- itself
-
getGssapi
public java.lang.Boolean getGssapi()
ssh option: -K (true)/-k (false)
-
local
public Ssh local(java.lang.String value)
ssh option: -L
-
getLocal
public java.lang.String getLocal()
ssh option: -L
-
loginName
public Ssh loginName(java.lang.String value)
ssh option: -l
-
getLoginName
public java.lang.String getLoginName()
ssh option: -l
-
masterMode
public Ssh masterMode(boolean value)
ssh option: -M
-
getMasterMode
public boolean getMasterMode()
ssh option: -M
-
macSpec
public Ssh macSpec(java.lang.String value)
ssh option: -m
-
getMacSpec
public java.lang.String getMacSpec()
ssh option: -m
-
noRemoteExecute
public Ssh noRemoteExecute(boolean value)
ssh option: -N
-
getNoRemoteExecute
public boolean getNoRemoteExecute()
ssh option: -N
-
fromNull
public Ssh fromNull(boolean value)
ssh option: -n
-
getFromNull
public boolean getFromNull()
ssh option: -n
-
controlCommand
public Ssh controlCommand(java.lang.String value)
ssh option: -O
-
getControlCommand
public java.lang.String getControlCommand()
ssh option: -O
-
option
public Ssh option(java.lang.String... value)
ssh option: -o
-
option
public Ssh option(java.util.List<java.lang.String> value)
ssh option: -o
-
getOption
public java.util.List<java.lang.String> getOption()
ssh option: -o
-
port
public Ssh port(int value)
ssh option: -p
-
getPort
public int getPort()
ssh option: -p
-
queryOption
public Ssh queryOption(java.lang.String value)
ssh option: -Q
-
getQueryOption
public java.lang.String getQueryOption()
ssh option: -Q
-
quiet
public Ssh quiet(boolean value)
ssh option: -q
-
getQuiet
public boolean getQuiet()
ssh option: -q
-
remote
public Ssh remote(java.lang.String value)
ssh option: -R
-
getRemote
public java.lang.String getRemote()
ssh option: -R
-
controlSocket
public Ssh controlSocket(java.lang.String value)
ssh option: -S
-
getControlSocket
public java.lang.String getControlSocket()
ssh option: -S
-
subsystem
public Ssh subsystem(boolean value)
ssh option: -s
-
getSubsystem
public boolean getSubsystem()
ssh option: -s
-
terminal
public Ssh terminal(java.lang.Boolean value)
Use null to set it to user/system default. Other true/false to turn on/off. ssh option: -t (true)/-T (false)- Parameters:
value- the value, null for default- Returns:
- itself
-
getTerminal
public java.lang.Boolean getTerminal()
ssh option: -t (true)/-T (false)
-
version
public Ssh version(boolean value)
ssh option: -v
-
getVersion
public boolean getVersion()
ssh option: -v
-
verbose
public Ssh verbose(int value)
ssh option: -v/-vv/-vvv
-
getVerbose
public int getVerbose()
ssh option: -v/-vv/-vvv
-
forwardTo
public Ssh forwardTo(java.lang.String value)
ssh option: -W
-
getForwardTo
public java.lang.String getForwardTo()
ssh option: -W
-
forwardTunnel
public Ssh forwardTunnel(java.lang.String value)
ssh option: -w
-
getForwardTunnel
public java.lang.String getForwardTunnel()
ssh option: -w
-
x11
public Ssh x11(java.lang.Boolean value)
Use null to set it to user/system default. Other true/false to turn on/off. ssh option: -X- Parameters:
value- the value, null for default- Returns:
- itself
-
getX11
public java.lang.Boolean getX11()
ssh option: -X
-
trustedX11
public Ssh trustedX11(boolean value)
ssh option: -Y
-
getTrustedX11
public boolean getTrustedX11()
ssh option: -Y
-
syslog
public Ssh syslog(boolean value)
ssh option: -y
-
getSyslog
public boolean getSyslog()
ssh option: -y
-
hostname
public Ssh hostname(java.lang.String value)
-
getHostname
public java.lang.String getHostname()
-
command
public Ssh command(java.lang.String value)
-
getCommand
public java.lang.String getCommand()
-
sshPass
public Ssh sshPass(SshPass value)
Sets the sshpass instance to use.- Parameters:
value- the instance, use null to not use sshpass- Returns:
- itselff
-
getSshPass
public SshPass getSshPass()
Returns the current sshpass instance in use.- Returns:
- the instance, null if none set
-
options
public java.util.List<java.lang.String> options() throws java.lang.ExceptionAssembles the arguments for the binary.- Specified by:
optionsin classAbstractBinary- Returns:
- the options
- Throws:
java.lang.Exception- if failed to determine binary
-
commandLineArgs
public java.util.List<java.lang.String> commandLineArgs() throws java.lang.ExceptionAssembles the full command-line arguments.- Specified by:
commandLineArgsin classAbstractBinary- Returns:
- the command-line arguments
- Throws:
java.lang.Exception- if failed to determine binary- See Also:
options()
-
description
protected java.lang.String description()
Returns a short description for the binary.- Specified by:
descriptionin classAbstractBinary- Returns:
- the description
-
getParser
protected net.sourceforge.argparse4j.inf.ArgumentParser getParser()
Configures and returns the commandline parser.- Overrides:
getParserin classAbstractBinaryWithTimeout- Returns:
- the parser
-
setOptions
protected boolean setOptions(net.sourceforge.argparse4j.inf.Namespace ns)
Sets the parsed options.- Overrides:
setOptionsin classAbstractBinaryWithTimeout- Parameters:
ns- the parsed options- Returns:
- if successfully set
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionFor running from the command-line.- Parameters:
args- the arguments- Throws:
java.lang.Exception
-
-