public final class SSH extends Object implements Shell
This class implements Shell interface. In order to use
it, just make an instance and call
exec(String,InputStream,OutputStream,OutputStream) exec()}:
String hello = new Shell.Plain(
new SSH(
"ssh.example.com", 22,
"yegor", "-----BEGIN RSA PRIVATE KEY-----..."
)
).exec("echo 'Hello, world!'");
It is highly recommended to use classes from Shell interface,
they will simplify operations.
Shell.Empty, Shell.Plain, Shell.Safe, Shell.Verbose| Modifier and Type | Field and Description |
|---|---|
static int |
PORT
Default SSH port.
|
| Constructor and Description |
|---|
SSH(InetAddress adr,
int prt,
String user,
URL priv)
Constructor.
|
SSH(InetAddress adr,
String user,
String priv)
Constructor.
|
SSH(InetAddress adr,
String user,
URL priv)
Constructor.
|
SSH(String adr,
int prt,
String user,
String priv)
Constructor.
|
SSH(String adr,
int prt,
String user,
URL priv)
Constructor.
|
SSH(String adr,
String user,
String priv)
Constructor.
|
SSH(String adr,
String user,
URL priv)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
escape(String arg)
Escape SSH argument.
|
int |
exec(String command,
InputStream stdin,
OutputStream stdout,
OutputStream stderr)
Execute and return exit code.
|
public static final int PORT
public SSH(String adr, String user, URL priv) throws IOException
adr - IP addressuser - Loginpriv - Private SSH keyIOException - If failspublic SSH(InetAddress adr, String user, URL priv) throws IOException
adr - IP addressuser - Loginpriv - Private SSH keyIOException - If failspublic SSH(String adr, String user, String priv) throws UnknownHostException
adr - IP addressuser - Loginpriv - Private SSH keyUnknownHostException - If failspublic SSH(InetAddress adr, String user, String priv) throws UnknownHostException
adr - IP addressuser - Loginpriv - Private SSH keyUnknownHostException - If failspublic SSH(String adr, int prt, String user, URL priv) throws IOException
adr - IP addressprt - Port of serveruser - Loginpriv - Private SSH keyIOException - If failspublic SSH(InetAddress adr, int prt, String user, URL priv) throws IOException
adr - IP addressprt - Port of serveruser - Loginpriv - Private SSH keyIOException - If failspublic SSH(String adr, int prt, String user, String priv) throws UnknownHostException
adr - IP addressprt - Port of serveruser - Loginpriv - Private SSH keyUnknownHostException - If failspublic int exec(String command, InputStream stdin, OutputStream stdout, OutputStream stderr) throws IOException
Shellexec in interface Shellcommand - Commandstdin - Stdin (will be closed)stdout - Stdout (will be closed)stderr - Stderr (will be closed)IOException - If failsCopyright © 2012–2015 jcabi.com. All rights reserved.