public interface ClientSession extends Session
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.Session.AttributeKey<T>, Session.TimeoutStatus
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 |
---|---|
void |
addPasswordIdentity(String password) |
void |
addPublicKeyIdentity(KeyPair key) |
AuthFuture |
auth()
Starts the authentication process.
|
AuthFuture |
authAgent(String username)
Deprecated.
Use
auth() instead |
AuthFuture |
authInteractive(String username,
String password)
Deprecated.
Use
auth() instead |
AuthFuture |
authPassword(String username,
String password)
Deprecated.
Use
auth() instead |
AuthFuture |
authPublicKey(String username,
KeyPair key)
Deprecated.
Use
auth() instead |
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.
|
ScpClient |
createScpClient()
Create an SCP client from this session.
|
SftpClient |
createSftpClient()
Create an SFTP client from this session.
|
ChannelShell |
createShellChannel()
Create a channel to start a shell.
|
ChannelSubsystem |
createSubsystemChannel(String subsystem)
Create a subsystem channel.
|
ClientFactoryManager |
getFactoryManager()
Return ClientFactoryManager for this session.
|
Map<Object,Object> |
getMetadataMap()
Access to the metadata.
|
UserInteraction |
getUserInteraction() |
void |
setUserInteraction(UserInteraction userInteraction) |
SshdSocketAddress |
startDynamicPortForwarding(SshdSocketAddress local)
Start dynamic local port forwarding using a SOCKS proxy.
|
SshdSocketAddress |
startLocalPortForwarding(SshdSocketAddress local,
SshdSocketAddress remote)
Start forwarding the given local address on the client to the given address on the server.
|
SshdSocketAddress |
startRemotePortForwarding(SshdSocketAddress remote,
SshdSocketAddress local)
Start forwarding tcpip from the given address on the server to the
given address on the client.
|
void |
stopDynamicPortForwarding(SshdSocketAddress local)
Stop a previously started dynamic port forwarding.
|
void |
stopLocalPortForwarding(SshdSocketAddress local)
Stop forwarding the given local address.
|
void |
stopRemotePortForwarding(SshdSocketAddress remote)
Stop forwarding of the given remote address.
|
SshFuture |
switchToNoneCipher()
Switch to a none cipher for performance.
|
int |
waitFor(int mask,
long timeout)
Wait for a specific state.
|
addListener, createBuffer, createBuffer, exceptionCaught, getAttribute, getAuthTimeout, getClientVersion, getIdleTimeout, getIntProperty, getIoSession, getNegotiatedKexParameter, getServerVersion, getService, getTimeoutStatus, getUsername, reExchangeKeys, removeListener, request, resetIdleTimeout, setAttribute, writePacket, writePacket
static final int TIMEOUT
static final int CLOSED
static final int WAIT_AUTH
static final int AUTHED
void addPasswordIdentity(String password)
void addPublicKeyIdentity(KeyPair key)
UserInteraction getUserInteraction()
void setUserInteraction(UserInteraction userInteraction)
AuthFuture auth() throws IOException
addPasswordIdentity(String)
or addPublicKeyIdentity(java.security.KeyPair)
.IOException
addPasswordIdentity(String)
,
addPublicKeyIdentity(java.security.KeyPair)
@Deprecated AuthFuture authAgent(String username) throws IOException
auth()
insteadIOException
auth()
@Deprecated AuthFuture authPassword(String username, String password) throws IOException
auth()
insteadIOException
auth()
@Deprecated AuthFuture authInteractive(String username, String password) throws IOException
auth()
insteadIOException
auth()
@Deprecated AuthFuture authPublicKey(String username, KeyPair key) throws IOException
auth()
insteadIOException
auth()
ClientChannel createChannel(String type) throws IOException
createChannel(type, null)
.IOException
ClientChannel createChannel(String type, String subType) throws IOException
IOException
ChannelShell createShellChannel() throws IOException
IOException
ChannelExec createExecChannel(String command) throws IOException
IOException
ChannelSubsystem createSubsystemChannel(String subsystem) throws IOException
IOException
ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
IOException
ScpClient createScpClient()
SftpClient createSftpClient() throws IOException
IOException
SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
IOException
void stopLocalPortForwarding(SshdSocketAddress local) throws IOException
IOException
SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException
IOException
void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException
IOException
SshdSocketAddress startDynamicPortForwarding(SshdSocketAddress local) throws IOException
local
- IOException
void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException
local
- IOException
int waitFor(int mask, long timeout)
CloseFuture close(boolean immediately)
ClientFactoryManager getFactoryManager()
getFactoryManager
in interface Session
SshFuture switchToNoneCipher() throws IOException
SshFuture
that can be used to wait for the exchange
to be finishedIOException
- if a key exchange is already runningCopyright © 2008–2018 The Apache Software Foundation. All rights reserved.