org.apache.sshd
Interface ClientSession

All Known Implementing Classes:
ClientSessionImpl

public interface ClientSession

An authenticated session to a given SSH server A client session is established using the 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.

Author:
Apache MINA SSHD Project

Field Summary
static int AUTHED
           
static int CLOSED
           
static int TIMEOUT
           
static int WAIT_AUTH
           
 
Method Summary
 AuthFuture authAgent(java.lang.String username)
          Authenticate the session with the given username using an ssh agent.
 AuthFuture authPassword(java.lang.String username, java.lang.String password)
          Authenticate the session with the given username and password.
 AuthFuture authPublicKey(java.lang.String username, java.security.KeyPair key)
          Authenticate the session with the gien username and public key.
 CloseFuture close(boolean immediately)
          Close this session.
 ClientChannel createChannel(java.lang.String type)
          Create a channel of the given type.
 ClientChannel createChannel(java.lang.String type, java.lang.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(java.lang.String command)
          Create a channel to execute a command.
 ChannelShell createShellChannel()
          Create a channel to start a shell.
 ChannelSubsystem createSubsystemChannel(java.lang.String subsystem)
          Create a subsystem channel.
 java.util.Map<java.lang.Object,java.lang.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.
 

Field Detail

TIMEOUT

static final int TIMEOUT
See Also:
Constant Field Values

CLOSED

static final int CLOSED
See Also:
Constant Field Values

WAIT_AUTH

static final int WAIT_AUTH
See Also:
Constant Field Values

AUTHED

static final int AUTHED
See Also:
Constant Field Values
Method Detail

authAgent

AuthFuture authAgent(java.lang.String username)
                     throws java.io.IOException
Authenticate the session with the given username using an ssh agent.

Throws:
java.io.IOException

authPassword

AuthFuture authPassword(java.lang.String username,
                        java.lang.String password)
                        throws java.io.IOException
Authenticate the session with the given username and password.

Throws:
java.io.IOException

authPublicKey

AuthFuture authPublicKey(java.lang.String username,
                         java.security.KeyPair key)
                         throws java.io.IOException
Authenticate the session with the gien username and public key.

Throws:
java.io.IOException

createChannel

ClientChannel createChannel(java.lang.String type)
                            throws java.lang.Exception
Create a channel of the given type. Same as calling createChannel(type, null).

Throws:
java.lang.Exception

createChannel

ClientChannel createChannel(java.lang.String type,
                            java.lang.String subType)
                            throws java.lang.Exception
Create a channel of the given type and subtype.

Throws:
java.lang.Exception

createShellChannel

ChannelShell createShellChannel()
                                throws java.lang.Exception
Create a channel to start a shell.

Throws:
java.lang.Exception

createExecChannel

ChannelExec createExecChannel(java.lang.String command)
                              throws java.lang.Exception
Create a channel to execute a command.

Throws:
java.lang.Exception

createSubsystemChannel

ChannelSubsystem createSubsystemChannel(java.lang.String subsystem)
                                        throws java.lang.Exception
Create a subsystem channel.

Throws:
java.lang.Exception

createDirectTcpipChannel

ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local,
                                            SshdSocketAddress remote)
                                            throws java.lang.Exception
Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.

Throws:
java.lang.Exception

startLocalPortForwarding

void startLocalPortForwarding(SshdSocketAddress local,
                              SshdSocketAddress remote)
                              throws java.lang.Exception
Start forwarding the given local address on the client to the given address on the server.

Throws:
java.lang.Exception

stopLocalPortForwarding

void stopLocalPortForwarding(SshdSocketAddress local)
                             throws java.lang.Exception
Stop forwarding the given local address.

Throws:
java.lang.Exception

startRemotePortForwarding

void startRemotePortForwarding(SshdSocketAddress remote,
                               SshdSocketAddress local)
                               throws java.lang.Exception
Start forwarding tcpip from the given address on the server to the given address on the client. The remote host name is the address to bind to on the server:

Throws:
java.lang.Exception

stopRemotePortForwarding

void stopRemotePortForwarding(SshdSocketAddress remote)
                              throws java.lang.Exception
Stop forwarding of the given remote address.

Throws:
java.lang.Exception

waitFor

int waitFor(int mask,
            long timeout)
Wait for a specific state.


close

CloseFuture close(boolean immediately)
Close this session.


getMetadataMap

java.util.Map<java.lang.Object,java.lang.Object> getMetadataMap()
Access to the metadata.



Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.