org.objectweb.proactive.core.ssh
Class SshTunnel
java.lang.Object
org.objectweb.proactive.core.ssh.SshTunnel
- public class SshTunnel
- extends java.lang.Object
- Author:
- mlacage
This class implements a very simple wrapper on top of the jsch
library. Most notably, it implements thread-safe and exception-safe
creation and destruction of SSH tunnels.
Thread-safety is achieved by using a single global lock whenever
we need to access the non-thread-safe jsch library for tunnel
creation or destruction operations. This global lock is stored in
JSchSingleton and is accessed with the acquireLock and releaseLock
methods
Constructor Summary |
SshTunnel(java.lang.String distantHost,
int distantPort)
Authenticate with the ssh server on the distantHost if needed (authenticated
connections are cached). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SshTunnel
public SshTunnel(java.lang.String distantHost,
int distantPort)
throws java.io.IOException
- Authenticate with the ssh server on the distantHost if needed (authenticated
connections are cached). The ssh server is expected to be listening on port
proactive.ssh.port. If this property is not set, the server is assumed to be
listening on distantHost:22. The Authentication is performed with the username
proactive.ssh.username if this property is set. It is performed with the value of
user.name otherwise (this is supposed to be the username of the user running this
JVM). The SSH Authentication is performed with the standard public/private key
authentication. The private key used by this client is either any of the private
keys located in proactive.ssh.key_directory if it is set or any of the private
keys found in user.home/.ssh/.
The public key of the server to which we connect is verified with the file
proactive.ssh.known_hosts if this property is set of user.home/.ssh/known_hosts.
Once authentication is performed, a tunnel is established from
localhost:randomPort to distantHost:distantPort. The randomPort can be otained from
this Tunnel with the getPort method after this constructor has completed
successfully.
- Parameters:
distantHost
- the name of the machine to which a tunnel must be established.distantPort
- the port number on the distant machine to which a tunnel must
be established
- Throws:
java.io.IOException
- an exception is thrown if either the authentication or the
tunnel establishment fails.
realClose
public void realClose()
throws java.lang.Exception
- Throws:
java.lang.Exception
getPort
public int getPort()
- This method returns the local port number which can be used
to access this tunnel.
This method cannot fail.
getInetAddress
public java.net.InetAddress getInetAddress()
throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
getDistantHost
public java.lang.String getDistantHost()
getDistantPort
public int getDistantPort()
Copyright ? October 2004 INRIA All Rights Reserved.