public class SshTools extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
SshTools.PortForwardingProperties
Defines local or remote port forwarding properties.
|
| Modifier and Type | Method and Description |
|---|---|
static com.trilead.ssh2.Connection |
connect(String server)
Connect to SSH server.
|
static com.trilead.ssh2.Connection |
connect(String host,
int port,
String username,
String password)
Connect to SSH server.
|
static com.numdata.oss.db.JdbcDataSource |
createJdbcDataSource(String sshServer,
String dbServer,
int dbPort,
String jdbcDriver,
String jdbcUrl,
String jdbcUser,
String jdbcPassword)
Create
JdbcDataSource. |
static int |
createLocalPortForwarder(com.trilead.ssh2.Connection connection,
SshTools.PortForwardingProperties properties)
Create local port forwarding based on the specified
SshTools.PortForwardingProperties. |
static int |
createLocalPortForwarder(com.trilead.ssh2.Connection connection,
String targetHost,
int targetPort)
Create port forwarding tunnel to the specified target host and port and
return the local TCP port through which it can be accessed.
|
static int |
getFreeLocalPort()
Get any free local TCP port (typically used for local port forwarding).
|
static com.numdata.oss.ensemble.Quartet<String,Integer,String,String> |
parseOptions(String server)
Parse SSH server specification.
|
static int |
requestRemotePortForwarding(com.trilead.ssh2.Connection connection,
SshTools.PortForwardingProperties properties)
Request remote port forwarding based on the specified
SshTools.PortForwardingProperties. |
public static com.trilead.ssh2.Connection connect(@Nullable
String server)
throws IOException
server - SSH server specification (<user>:<pass>@<host>[':'<port>]).IOException - if the connection could not be established.IllegalArgumentException - if the specification is badly
formatted.@Nullable public static com.numdata.oss.ensemble.Quartet<String,Integer,String,String> parseOptions(@Nullable String server)
<user>:<pass>@<host>[':'<port>].
server - SSH server specification.Quartet with SSH server host, server port, user name, and
password; null if server is empty.IllegalArgumentException - if the specification is badly
formatted.@NotNull
public static com.trilead.ssh2.Connection connect(@NotNull
String host,
int port,
@NotNull
String username,
@NotNull
String password)
throws IOException
host - SSH server host.port - SSH server port.username - User name for authentication.password - Password for authentication.IOException - if the connection could not be established.public static com.numdata.oss.db.JdbcDataSource createJdbcDataSource(@Nullable
String sshServer,
@NotNull
String dbServer,
int dbPort,
String jdbcDriver,
@NotNull
String jdbcUrl,
String jdbcUser,
String jdbcPassword)
throws IOException,
SQLException
JdbcDataSource.sshServer - Optional SSH server specification (<user>:<pass>@<host>[':'<port>]).dbServer - Database server host.dbPort - TCP port of database server.jdbcDriver - JDBC driver name.jdbcUrl - JDBC URL format ({0}=host, {1}=port).jdbcUser - JDBC user name.jdbcPassword - JDBC password.JdbcDataSource.IllegalArgumentException - if the specification is badly
formatted.IOException - if the SSH connection could not be established.SQLException - if an error occurs while accessing the database.public static int createLocalPortForwarder(@NotNull
com.trilead.ssh2.Connection connection,
String targetHost,
int targetPort)
throws IOException
connection - Connection to create port forwarding on.targetHost - Target host to connect to.targetPort - TCP port to connect to.IOException - if the tunnel could not be created.public static int createLocalPortForwarder(@NotNull
com.trilead.ssh2.Connection connection,
@NotNull
SshTools.PortForwardingProperties properties)
throws IOException
SshTools.PortForwardingProperties.connection - Connection to create port forwardings on.properties - Port forwarding properties.IOException - port forwarding failed.public static int requestRemotePortForwarding(@NotNull
com.trilead.ssh2.Connection connection,
@NotNull
SshTools.PortForwardingProperties properties)
throws IOException
SshTools.PortForwardingProperties.connection - Connection to request port forwardings on.properties - Port forwarding properties.IOException - port forwarding failed.public static int getFreeLocalPort()
throws IOException
IOException - if no free local TCP port is available.Copyright © 2018 Numdata BV. All rights reserved.