当前位置: 首页>>代码示例>>Java>>正文


Java SSHClient.loadKnownHosts方法代码示例

本文整理汇总了Java中net.schmizz.sshj.SSHClient.loadKnownHosts方法的典型用法代码示例。如果您正苦于以下问题:Java SSHClient.loadKnownHosts方法的具体用法?Java SSHClient.loadKnownHosts怎么用?Java SSHClient.loadKnownHosts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.schmizz.sshj.SSHClient的用法示例。


在下文中一共展示了SSHClient.loadKnownHosts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeCommand

import net.schmizz.sshj.SSHClient; //导入方法依赖的package包/类
@Override
public String executeCommand(ShellCommand aCommand) throws IOException {
    SSHClient ssh = new SSHClient();
    ssh.loadKnownHosts();
    ssh.connect("localhost", 2222);
    try {
        ssh.authPublickey("root");
        try (Session session = ssh.startSession()) {
            Session.Command command = session.exec(aCommand.getCommand());
            String text = IOUtils.readFully(command.getInputStream()).toString();
            command.join(5, TimeUnit.SECONDS);
            return text;
        }
    } finally {
        ssh.disconnect();
    }
}
 
开发者ID:evsinev,项目名称:docker-network-veth,代码行数:18,代码来源:CommandServiceSsh.java

示例2: connect_to_virtual_box

import net.schmizz.sshj.SSHClient; //导入方法依赖的package包/类
@Test
public void connect_to_virtual_box() throws IOException {
    SSHClient ssh = new SSHClient();
    ssh.loadKnownHosts();
    ssh.connect("localhost", 2222);
    try {
        ssh.authPublickey("root");
        try (Session session = ssh.startSession()) {
            Session.Command command = session.exec("ls -l");
            System.out.println(IOUtils.readFully(command.getInputStream()).toString());
            command.join(5, TimeUnit.SECONDS);
        }
    } finally {
        ssh.disconnect();
    }

}
 
开发者ID:evsinev,项目名称:docker-network-veth,代码行数:18,代码来源:SshClientTest.java

示例3: connect

import net.schmizz.sshj.SSHClient; //导入方法依赖的package包/类
@Override
public void connect(String host) throws IOException {
    sshClient = new SSHClient();
    if (knownHosts == null) {
        sshClient.loadKnownHosts();
    } else {
        sshClient.loadKnownHosts(knownHosts.toFile());
    }

    sshClient.connect(host);

    if (privateKey != null) {
        sshClient.authPublickey(user, privateKey.toString());
    } else if (password != null) {
        sshClient.authPassword(user, password);
    } else {
        throw new RuntimeException("Either privateKey nor password is set. Please call one of the auth method.");
    }
}
 
开发者ID:sparsick,项目名称:comparison-java-ssh-libs,代码行数:20,代码来源:SshJClient.java

示例4: configureSsh

import net.schmizz.sshj.SSHClient; //导入方法依赖的package包/类
private SSHClient configureSsh() throws IOException {
    SSHClient sshClient = new SSHClient();
    sshClient.loadKnownHosts();
    sshClient.connect(eyeballsConfiguration.getSftpDestinationHost(), eyeballsConfiguration.getSftpRemotePort());
    sshClient.authPublickey(eyeballsConfiguration.getSftpUsername());
    sshClient.useCompression();
    return sshClient;
}
 
开发者ID:chriskearney,项目名称:eyeballs,代码行数:9,代码来源:SftpMotionEventConsumer.java

示例5: connectWithSSH

import net.schmizz.sshj.SSHClient; //导入方法依赖的package包/类
private SSHClient connectWithSSH() throws IOException {
  SSHClient ssh = mSSHClientFactory.newSSHClient();
  ssh.loadKnownHosts();
  ssh.connect(mRemoteInetAddress);
  ssh.authPublickey(mUsername, mPrivateKeyPath.toString());
  return ssh;
}
 
开发者ID:gregorias,项目名称:dfuntest,代码行数:8,代码来源:SSHEnvironment.java


注:本文中的net.schmizz.sshj.SSHClient.loadKnownHosts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。