public final class Sshd extends Object implements Closeable
It is a convenient class for unit testing of your SSH clients:
try (SSHD sshd = new SSHD()) { String uptime = new Shell.Plain( SSH(sshd.host(), sshd.login(), sshd.port(), sshd.key()) ).exec("uptime"); }
If you forget to call close()
, SSH daemon will be
up and running until a shutdown of the JVM.
Modifier and Type | Method and Description |
---|---|
void |
close() |
Shell |
connect()
Get an instance of Shell.
|
File |
home()
Get home dir.
|
static String |
host()
Get host of SSH.
|
static String |
key()
Get private SSH key for login.
|
static String |
login()
Get user name to login.
|
int |
port()
Get port.
|
public Sshd() throws IOException
IOException
- If failspublic Sshd(File path) throws IOException
path
- Directory to work inIOException
- If failspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public File home()
public static String login()
public static String host()
public int port()
Don't forget to start
public static String key() throws IOException
IOException
- If failspublic Shell connect() throws IOException
IOException
- If failsCopyright © 2012–2018 jcabi.com. All rights reserved.