Package com.jcabi.ssh
Class Sshd
- java.lang.Object
-
- com.jcabi.ssh.Sshd
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class Sshd extends Object implements Closeable
Test SSHD daemon (only for Linux).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.- Since:
- 1.0
- Suppressed Checkstyle violations:
- MultipleStringLiteralsCheck (500 lines), ClassDataAbstractionCouplingCheck (500 lines)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Shellconnect()Get an instance of Shell.Filehome()Get home dir.static Stringhost()Get host of SSH.static Stringkey()Get private SSH key for login.static Stringlogin()Get user name to login.intport()Get port.
-
-
-
Constructor Detail
-
Sshd
public Sshd() throws IOExceptionCtor.- Throws:
IOException- If fails- Since:
- 1.5
-
Sshd
public Sshd(File path) throws IOException
Ctor.- Parameters:
path- Directory to work in- Throws:
IOException- If fails
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
home
public File home()
Get home dir.- Returns:
- Dir
-
login
public static String login()
Get user name to login.- Returns:
- User name
-
host
public static String host()
Get host of SSH.- Returns:
- Hostname
- Since:
- 1.1
-
port
public int port()
Get port.Don't forget to start
- Returns:
- Port number
- Since:
- 1.1
-
key
public static String key() throws IOException
Get private SSH key for login.- Returns:
- Key
- Throws:
IOException- If fails
-
connect
public Shell connect() throws IOException
Get an instance of Shell.- Returns:
- Shell
- Throws:
IOException- If fails
-
-