public class JschConfigSessionFactory extends SshSessionFactory
$HOME/.ssh
.
This is the default implementation used by JGit and provides most of the compatibility necessary to match OpenSSH, a popular implementation of SSH used by C Git.
The factory does not provide UI behavior. Override the method
configure(org.eclipse.jgit.transport.OpenSshConfig.Host, Session)
to
supply appropriate UserInfo
to the session.
Constructor and Description |
---|
JschConfigSessionFactory() |
Modifier and Type | Method and Description |
---|---|
protected void |
configure(OpenSshConfig.Host hc,
com.jcraft.jsch.Session session)
Provide additional configuration for the session based on the host
information.
|
protected void |
configureJSch(com.jcraft.jsch.JSch jsch)
Provide additional configuration for the JSch instance.
|
protected com.jcraft.jsch.JSch |
createDefaultJSch(FS fs)
Create default instance of jsch
|
protected com.jcraft.jsch.Session |
createSession(OpenSshConfig.Host hc,
String user,
String host,
int port,
FS fs)
Create a new remote session for the requested address.
|
protected com.jcraft.jsch.JSch |
getJSch(OpenSshConfig.Host hc,
FS fs)
Obtain the JSch used to create new sessions.
|
RemoteSession |
getSession(URIish uri,
CredentialsProvider credentialsProvider,
FS fs,
int tms)
Opens (or reuses) a session to a host.
|
String |
getType()
The name of the type of session factory.
|
getInstance, getLocalUserName, releaseSession, setInstance
public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException
getSession
in class SshSessionFactory
uri
- URI of the remote host to connect tocredentialsProvider
- provider to support authentication, may be null
if no
user input for authentication is neededfs
- the file system abstraction to use for certain file
operations, such as reading configuration filestms
- connection timeout for creating the session, in millisecondsuri
TransportException
- if the session could not be createdpublic String getType()
SshSessionFactory
getType
in class SshSessionFactory
protected com.jcraft.jsch.Session createSession(OpenSshConfig.Host hc, String user, String host, int port, FS fs) throws com.jcraft.jsch.JSchException
hc
- host configurationuser
- login to authenticate as.host
- server name to connect to.port
- port number of the SSH daemon (typically 22).fs
- the file system abstraction which will be necessary to
perform certain file system operations.com.jcraft.jsch.JSchException
- the session could not be created.protected void configureJSch(com.jcraft.jsch.JSch jsch)
IdentityRepository
.jsch
- jsch instanceprotected void configure(OpenSshConfig.Host hc, com.jcraft.jsch.Session session)
UserInfo
.hc
- host configurationsession
- session to configureprotected com.jcraft.jsch.JSch getJSch(OpenSshConfig.Host hc, FS fs) throws com.jcraft.jsch.JSchException
hc
- host configurationfs
- the file system abstraction which will be necessary to
perform certain file system operations.com.jcraft.jsch.JSchException
- the user configuration could not be created.protected com.jcraft.jsch.JSch createDefaultJSch(FS fs) throws com.jcraft.jsch.JSchException
fs
- the file system abstraction which will be necessary to perform
certain file system operations.com.jcraft.jsch.JSchException
- known host keys cannot be loaded.Copyright © 2020 Eclipse JGit Project. All rights reserved.