本文整理汇总了Java中com.sshtools.j2ssh.transport.IgnoreHostKeyVerification类的典型用法代码示例。如果您正苦于以下问题:Java IgnoreHostKeyVerification类的具体用法?Java IgnoreHostKeyVerification怎么用?Java IgnoreHostKeyVerification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IgnoreHostKeyVerification类属于com.sshtools.j2ssh.transport包,在下文中一共展示了IgnoreHostKeyVerification类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: connectSsh
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification; //导入依赖的package包/类
/**
* connect to host
*
* @return
* @throws Exception
*/
private static SshClient connectSsh() throws Exception {
SshClient ssh = new SshClient();
HostKeyVerification host = new IgnoreHostKeyVerification();
String hostStr = getBundle().getString("ssh.host");
ssh.connect(hostStr, host);
PasswordAuthenticationClient auth = new PasswordAuthenticationClient();
auth.setUsername(getBundle().getString("ssh.user"));
auth.setPassword(getBundle().getString("ssh.pwd"));
int result = ssh.authenticate(auth);
System.out.println("Status " + result);
if ((result == AuthenticationProtocolState.CANCELLED) || (result == AuthenticationProtocolState.FAILED)) {
throw new Exception("Authentication Error.");
}
return ssh;
}
开发者ID:qmetry,项目名称:qaf,代码行数:24,代码来源:SshUtil.java
示例2: connect
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification; //导入依赖的package包/类
public boolean connect(String host, String user, String password) {
try {
// Connect to host ignoring host key verification
ssh.connect(host, new IgnoreHostKeyVerification());
PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
pwd.setUsername(user);
pwd.setPassword(password);
status = ssh.authenticate(pwd);
if (status == AuthenticationProtocolState.COMPLETE)
return true;
else
return false;
} catch (IOException ioe) {
System.out.println("Error in connecting to "+host+" with user "+user);
return false;
}
}
开发者ID:vagfed,项目名称:hmcScanner,代码行数:21,代码来源:SSHManager.java
示例3: makeConnection
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification; //导入依赖的package包/类
/***********************************************************************/
public synchronized Connection makeConnection(String database, DatabaseConfiguration originalConfiguration)
{
int port = counter++;
DatabaseConfiguration config = new DatabaseConfiguration(originalConfiguration.getDataSourceName(), originalConfiguration.getDriver(), originalConfiguration.getProtocol(), "localhost", "" + port, database, originalConfiguration.getUserName(), originalConfiguration.getPassword(), originalConfiguration.getType());
try
{
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
SshClient ssh = new SshClient();
ssh.setSocketTimeout(60000);
ssh.connect(originalConfiguration.getServer(), new IgnoreHostKeyVerification());
PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
pwd.setUsername(originalConfiguration.getUserName());
pwd.setPassword(originalConfiguration.getPassword());
ssh.authenticate(pwd);
ForwardingClient client = ssh.getForwardingClient();
client.addLocalForwarding(config.getProtocol(), "0.0.0.0", config.getPort(), "localhost", originalConfiguration.getPort());
client.startLocalForwarding(config.getProtocol());
return new SshConnection(ssh, config.makeConnection());
}
catch (IOException ie)
{
throw ObjectUtils.throwAsError(ie);
}
}
开发者ID:approvals,项目名称:ApprovalTests.Java,代码行数:26,代码来源:SshDatabaseWrapper.java
示例4: connectKey
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification; //导入依赖的package包/类
public boolean connectKey(String host, String user, String keyFile) {
try {
// Connect to host ignoring host key verification
ssh.connect(host, new IgnoreHostKeyVerification());
PublicKeyAuthenticationClient sshClient = new PublicKeyAuthenticationClient();
SshPrivateKeyFile sshPrivKeyFile = SshPrivateKeyFile.parse(new File(keyFile));
SshPrivateKey sshPrivKey = null;
try {
sshPrivKey = sshPrivKeyFile.toPrivateKey("");
} catch (InvalidSshKeyException iske) {
System.out.println("Wrong key or unsupported usage of passphrase.");
return false;
}
sshClient.setKey(sshPrivKey);
sshClient.setUsername(user);
status = ssh.authenticate(sshClient);
if (status == AuthenticationProtocolState.COMPLETE)
return true;
else
return false;
} catch (IOException ioe) {
System.out.println("Error in connecting to "+host+" with keyfile "+keyFile);
System.out.println(ioe);
return false;
}
}
开发者ID:vagfed,项目名称:hmcScanner,代码行数:32,代码来源:SSHManager.java
示例5: connect
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification; //导入依赖的package包/类
/**
* Connect. This action simulates all the actions required for a SSH connection
*
* @param host the hostname of the host you want to connect to
* @param port the port of the host you want to connect to
* @param username the username required for authentication
* @param password the password required for authentication
* @return the ssh client you connected to
* @throws IOException Signals that an I/O exception has occurred.
*/
public static SshClient connect(String host, int port,String username,String password) throws IOException {
SSH_LOG.info("Connecting to " + host);
SshClient ssh = new SshClient();
ssh.connect(host, port, new IgnoreHostKeyVerification());
PasswordAuthenticationClient passwordAuthenticationClient = new PasswordAuthenticationClient();
passwordAuthenticationClient.setUsername(username);
passwordAuthenticationClient.setPassword(password);
int result = ssh.authenticate(passwordAuthenticationClient);
if (result != AuthenticationProtocolState.COMPLETE) {
throw new IOException("Login to " + host + ":" + port + " "+ username + "/" + password + " failed");
}
SSH_LOG.info("Connected " + host);
return ssh;
}
开发者ID:persado,项目名称:stevia,代码行数:25,代码来源:SSHUtils.java
示例6: sshLogin
import com.sshtools.j2ssh.transport.IgnoreHostKeyVerification; //导入依赖的package包/类
/************************************************************************/
private static SftpClient sshLogin(FTPConfig config, SshClient ssh) throws IOException
{
ssh.setSocketTimeout(60000);
ssh.connect(config.host, new IgnoreHostKeyVerification());
PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
pwd.setUsername(config.userName);
pwd.setPassword(config.password);
ssh.authenticate(pwd);
SftpClient sftp = ssh.openSftpClient();
return sftp;
}
开发者ID:approvals,项目名称:ApprovalTests.Java,代码行数:13,代码来源:NetUtils.java
注:本文中的com.sshtools.j2ssh.transport.IgnoreHostKeyVerification类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论