本文整理了Java中com.jcraft.jsch.JSch.setHostKeyRepository()
方法的一些代码示例,展示了JSch.setHostKeyRepository()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSch.setHostKeyRepository()
方法的具体详情如下:
包路径:com.jcraft.jsch.JSch
类名称:JSch
方法名:setHostKeyRepository
[英]Sets the Host key repository. This will be used by sessions Session#connect in the future to validate the host keys offered by the remote hosts.
[中]设置主机密钥存储库。这将在将来的会话#connect中用于验证远程主机提供的主机密钥。
代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit
jsch.setConfigRepository(defaultJSch.getConfigRepository());
jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository());
jsch.addIdentity(identityKey);
byIdentityFile.put(identityKey, jsch);
代码示例来源:origin: net.oneandone/sushi
/** @param trySshAgent disable this if your ssh agent is configured, but you don't want to use it. */
public static JSch jsch(boolean trySshAgent) throws IOException {
JSch jsch;
jsch = new JSch();
if (trySshAgent) {
if (SshAgentSocket.isConfigured()) {
try {
SshAgent.configure(jsch);
} catch (NoClassDefFoundError e) {
// ok -- we have no ssh-agent dependencies
} catch (Throwable e) {
System.out.println("TODO: " + trySshAgent);
e.printStackTrace();
}
} else {
// don't try to connect to agent - it throws an exception if the environment variable is not defined
}
}
jsch.setHostKeyRepository(new AcceptAllHostKeyRepository());
return jsch;
}
代码示例来源:origin: com.sonyericsson.hudson.plugins.gerrit/gerrit-events
/**
* Creates and opens a SshConnection.
* @param host the host to connect to.
* @param port the port.
* @param authentication the authentication-info
* @throws SshException if something happens - usually due to bad config.
* @throws IOException if the unfortunate happens.
*/
public SshConnection(String host, int port, Authentication authentication) throws SshException, IOException {
logger.debug("connecting...");
try {
client = new JSch();
client.addIdentity(authentication.getPrivateKeyFile().getAbsolutePath(),
authentication.getPrivateKeyFilePassword());
client.setHostKeyRepository(new BlindHostKeyRepository());
connectSession = client.getSession(authentication.getUsername(), host, port);
connectSession.connect();
logger.debug("Connected: {}", connectSession.isConnected());
} catch (JSchException ex) {
throw new SshException(ex);
}
}
代码示例来源:origin: sonia.jgit/org.eclipse.jgit
jsch = new JSch();
configureJSch(jsch);
jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository());
jsch.addIdentity(identityKey);
byIdentityFile.put(identityKey, jsch);
代码示例来源:origin: com.axway.ats.framework/ats-core
this.jsch.setHostKeyRepository(hostKeyRepository);
} else {
if (StringUtils.isNullOrEmpty(this.trustedServerSSLCerfiticateFile)) {
addPublicKeyToHostKeyRepostitory(trustStore.getCertificate("cert").getPublicKey(),
hostKeyRepository);
this.jsch.setHostKeyRepository(hostKeyRepository);
} catch (Exception e) {
throw new Exception("Unable to add public key from certificate '"
代码示例来源:origin: org.hudsonci.plugins/gerrit-events
/**
* Creates and opens a SshConnection.
*
* @param host the host to connect to.
* @param port the port.
* @param authentication the authentication-info
* @throws SshException if something happens - usually due to bad config.
* @throws IOException if the unfortunate happens.
*/
protected SshConnectionImpl(String host, int port, Authentication authentication) throws SshException, IOException {
logger.debug("connecting...");
try {
client = new JSch();
client.addIdentity(authentication.getPrivateKeyFile().getAbsolutePath(),
authentication.getPrivateKeyFilePassword());
client.setHostKeyRepository(new BlindHostKeyRepository());
connectSession = client.getSession(authentication.getUsername(), host, port);
connectSession.connect();
logger.debug("Connected: {}", connectSession.isConnected());
connectSession.setServerAliveInterval(ALIVE_INTERVAL);
} catch (JSchException ex) {
throw new SshException(ex);
}
}
代码示例来源:origin: sonyxperiadev/gerrit-events
auth.getPrivateKeyFilePassword().getBytes("UTF-8"));
client.setHostKeyRepository(new BlindHostKeyRepository());
connectSession = client.getSession(auth.getUsername(), host, port);
connectSession.setConfig("PreferredAuthentications", "publickey");
代码示例来源:origin: jcabi/jcabi-ssh
jsch.setHostKeyRepository(new EasyRepo());
if (this.passphrase == null) {
jsch.addIdentity(file.getAbsolutePath());
代码示例来源:origin: com.jcabi/jcabi-ssh
jsch.setHostKeyRepository(new EasyRepo());
if (this.passphrase == null) {
jsch.addIdentity(file.getAbsolutePath());
代码示例来源:origin: berlam/github-bucket
jsch.setConfigRepository(defaultJSch.getConfigRepository());
jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository());
jsch.addIdentity(identityKey);
byIdentityFile.put(identityKey, jsch);
代码示例来源:origin: com.github.robtimus/sftp-fs
jsch.setHostKeyRepository(hostKeyRepository);
代码示例来源:origin: net.sf.sshapi/sshapi-jsch
client.setHostKeyRepository(new HostKeyRepositoryBridge(client.getHostKeyRepository()));
session = client.getSession(username, hostname, port);
final SocketFactory socketFactory = getConfiguration().getSocketFactory();
内容来源于网络,如有侵权,请联系作者删除!