public interface ClientSession
SshClient
.
Once the session has been created, the user has to authenticate
using either authPassword(String, String)
or
authPublicKey(String, java.security.KeyPair)
.
From this session, channels can be created using the
createChannel(String)
method. Multiple channels can
be created on a given session concurrently.
When using the client in an interactive mode, the
waitFor(int, long)
method can be used to listen to specific
events such as the session being established, authenticated or closed.
When a given session is no longer used, it must be closed using the
close(boolean)
method.Modifier and Type | Field and Description |
---|---|
static int |
AUTHED |
static int |
CLOSED |
static int |
TIMEOUT |
static int |
WAIT_AUTH |
Modifier and Type | Method and Description |
---|---|
AuthFuture |
authAgent(String username)
Authenticate the session with the given username using an ssh agent.
|
AuthFuture |
authPassword(String username,
String password)
Authenticate the session with the given username and password.
|
AuthFuture |
authPublicKey(String username,
KeyPair key)
Authenticate the session with the gien username and public key.
|
CloseFuture |
close(boolean immediately)
Close this session.
|
ClientChannel |
createChannel(String type)
Create a channel of the given type.
|
ClientChannel |
createChannel(String type,
String subType)
Create a channel of the given type and subtype.
|
ChannelDirectTcpip |
createDirectTcpipChannel(SshdSocketAddress local,
SshdSocketAddress remote)
Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.
|
ChannelExec |
createExecChannel(String command)
Create a channel to execute a command.
|
ChannelShell |
createShellChannel()
Create a channel to start a shell.
|
ChannelSubsystem |
createSubsystemChannel(String subsystem)
Create a subsystem channel.
|
Map<Object,Object> |
getMetadataMap()
Access to the metadata.
|
void |
startLocalPortForwarding(SshdSocketAddress local,
SshdSocketAddress remote)
Start forwarding the given local address on the client to the given address on the server.
|
void |
startRemotePortForwarding(SshdSocketAddress remote,
SshdSocketAddress local)
Start forwarding tcpip from the given address on the server to the
given address on the client.
|
void |
stopLocalPortForwarding(SshdSocketAddress local)
Stop forwarding the given local address.
|
void |
stopRemotePortForwarding(SshdSocketAddress remote)
Stop forwarding of the given remote address.
|
int |
waitFor(int mask,
long timeout)
Wait for a specific state.
|
static final int TIMEOUT
static final int CLOSED
static final int WAIT_AUTH
static final int AUTHED
AuthFuture authAgent(String username) throws IOException
IOException
AuthFuture authPassword(String username, String password) throws IOException
IOException
AuthFuture authPublicKey(String username, KeyPair key) throws IOException
IOException
ClientChannel createChannel(String type) throws Exception
createChannel(type, null)
.Exception
ClientChannel createChannel(String type, String subType) throws Exception
Exception
ChannelShell createShellChannel() throws Exception
Exception
ChannelExec createExecChannel(String command) throws Exception
Exception
ChannelSubsystem createSubsystemChannel(String subsystem) throws Exception
Exception
ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws Exception
Exception
void startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws Exception
Exception
void stopLocalPortForwarding(SshdSocketAddress local) throws Exception
Exception
void startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws Exception
Exception
void stopRemotePortForwarding(SshdSocketAddress remote) throws Exception
Exception
int waitFor(int mask, long timeout)
CloseFuture close(boolean immediately)
Copyright © 2008–2013 The Apache Software Foundation. All rights reserved.