• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java AgentProxyException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.jcraft.jsch.agentproxy.AgentProxyException的典型用法代码示例。如果您正苦于以下问题:Java AgentProxyException类的具体用法?Java AgentProxyException怎么用?Java AgentProxyException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AgentProxyException类属于com.jcraft.jsch.agentproxy包,在下文中一共展示了AgentProxyException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initSessionSshAgent

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
private Session initSessionSshAgent(String username, String socketPath, JSch jsch) throws JSchException {
  final Session session = jsch.getSession(username, myHost, myPort);
  session.setConfig("PreferredAuthentications", "publickey");

  try {
    ConnectorFactory cf = ConnectorFactory.getDefault();
    cf.setUSocketPath(socketPath);
    Connector con = cf.createConnector();
    IdentityRepository irepo = new RemoteIdentityRepository(con);
    jsch.setIdentityRepository(irepo);
    return session;
  } catch (AgentProxyException e) {
    throw new JSchException("Failed to connect to ssh agent.", e);
  }
}
 
开发者ID:JetBrains,项目名称:teamcity-deployer-plugin,代码行数:16,代码来源:SSHSessionProvider.java


示例2: OpenSSHAgentAuthenticator

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
public OpenSSHAgentAuthenticator() {
    try {
        proxy = new AgentProxy(new SSHAgentConnector(new JNAUSocketFactory()));
    }
    catch(AgentProxyException e) {
        log.warn(String.format("Agent proxy %s failed with %s", this, e));
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:9,代码来源:OpenSSHAgentAuthenticator.java


示例3: PageantAuthenticator

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
public PageantAuthenticator() {
    try {
        this.proxy = new AgentProxy(new PageantConnector());
    }
    catch(AgentProxyException e) {
        log.warn(String.format("Agent proxy %s failed with %s", this, e));
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:9,代码来源:PageantAuthenticator.java


示例4: newSession

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
private Session newSession() throws JSchException {
    JSch jSch = new JSch();
    try {
        jSch.setConfig("PreferredAuthentications", "publickey");

        if (hostInfo.isDoHostKeyChecks()) {
            jSch.setKnownHosts(userInfo.sshFolderLocation() + File.separator + "known_hosts");
        } else {
            jSch.setHostKeyRepository(new FakeHostKeyRepository());
        }

        if (userInfo.isUseAgentIdentities()) {
            Connector connector = ConnectorFactory.getDefault().createConnector();
            if (connector != null) {
                IdentityRepository identityRepository = new RemoteIdentityRepository(connector);
                jSch.setIdentityRepository(identityRepository);
            }
        }

        // add private key to the IdentityRepository. If using agent identities, this will add the private
        // key to the agent, if it is not already present.
        jSch.addIdentity(userInfo.privateKeyLocation().getAbsolutePath());

        session = jSch.getSession(userInfo.getUserName(), hostInfo.getHostname(), hostInfo.getPort());
        Long timeout = TimeUnit.SECONDS.toMillis(hostInfo.getTimeoutSeconds());
        session.setTimeout(timeout.intValue());
        session.setUserInfo(new PasswordlessEnabledUser(userInfo.getPassphrase()));
        return session;
    } catch (JSchException | AgentProxyException e) {
        String msg = ExecutionFailedException.userFriendlyCause(e.getMessage(), hostInfo.getHostname(), userInfo);
        throw new ExecutionFailedException(msg, e);
    }
}
 
开发者ID:RationaleEmotions,项目名称:SimpleSSH,代码行数:34,代码来源:JSchBackedSshKnowHowImpl.java


示例5: RemoteClient

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
public RemoteClient(Environment environment, DeploymentContext context, Logger logger) throws RemoteClientException {
    RemoteClient instance = this;

    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            instance.tryDisconnect();
        }
    });

    this.logger = logger;

    try {
        JSch shellClient = new JSch();
        shellClient.setKnownHosts(new FileInputStream(new File(System.getenv("HOME") + "/.ssh/known_hosts")));
        ConnectorFactory connectorFactory = ConnectorFactory.getDefault();
        Connector connector = connectorFactory.createConnector();
        Properties config = new java.util.Properties();
        config.put("PreferredAuthentications", "publickey");

        if (context.project().options().containsKey("check_host_keys")) {
            String option = (boolean) context.project().options().get("check_host_keys") ? "yes" : "no";
            JSch.setConfig("StrictHostKeyChecking", option);
            if (option.equals("no")) {
                logger.warn("WARNING: host key check is disabled!");
            }
        }

        if (connector != null) {
            IdentityRepository remoteIdentityRepository = new RemoteIdentityRepository(connector);
            shellClient.setIdentityRepository(remoteIdentityRepository);
        }
        for (Target target : environment.targets()) {
            sessions.add(new RemoteTarget(connect(shellClient, target, context, config), target, context, environment));
        }
    } catch (AgentProxyException | FileNotFoundException | JSchException e) {
        throw new RemoteClientException(e.getMessage());
    }
}
 
开发者ID:mobilecashout,项目名称:osprey,代码行数:39,代码来源:RemoteClient.java


示例6: createSshAgentConnector

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
@Nullable
private static Connector createSshAgentConnector() {
  Connector result = null;

  try {
    result = ConnectorFactory.getDefault().createConnector();
  }
  catch (AgentProxyException e) {
    LOG.info("Could not create ssh agent connector", e);
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SvnInteractiveAuthenticationProvider.java


示例7: defaultSshClientFactory

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
public static SshClient.Factory defaultSshClientFactory()
{
    return new SshClient.Factory()
    {
        int timeout = SystemUtils2.getIntegerProperty("org.excalibur.ssh.default.connection.timeout.ms", 60000);

        Optional<Connector> agentConnector = getAgentConnector();

        @Override
        public boolean isAgentAvailable()
        {
            return agentConnector.isPresent();
        }

        @Override
        public SshClient create(HostAndPort socket, LoginCredentials credentials)
        {
            return new JschSshClient(socket, credentials, timeout, agentConnector, new BackoffLimitedRetryHandler());
        }

        Optional<Connector> getAgentConnector()
        {
            try
            {
                return Optional.of(ConnectorFactory.getDefault().createConnector());
            }
            catch (final AgentProxyException e)
            {
                return Optional.absent();
            }
        }
    };
}
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:34,代码来源:SshClientFactory.java


示例8: main

import com.jcraft.jsch.agentproxy.AgentProxyException; //导入依赖的package包/类
public static void main(String[] args) throws AgentProxyException, IOException, JSchException
    {
        HostAndPort hostAndPort = HostAndPort.fromParts("ec2-54-83-158-5.compute-1.amazonaws.com", 22);
        LoginCredentials loginCredentials = LoginCredentials.builder().privateKey(System.getProperty("user.home") + "/.ec2/leite.pem").user("ubuntu")
                .build();

        SshClient client = SshClientFactory.defaultSshClientFactory().create(hostAndPort, loginCredentials);
        client.connect();

        ExecutableResponse response = client.execute("uname -a && date && uptime && who");
        System.out.println(response);

//        final OnlineChannel shell = client.shell();
//        shell.getInput().write("sudo apt-get install maven -y\n".getBytes());
//        shell.getInput().flush();
//
//        Thread t = new Thread(new Runnable()
//        {
//            @Override
//            public void run()
//            {
//                while (true)
//                {
//                    BufferedReader reader = new BufferedReader(new InputStreamReader(shell.getOutput(), Charsets.US_ASCII));
//                    String line;
//                    try
//                    {
//                        while ((line = reader.readLine()) != null)
//                        {
//                            System.out.println(line);
//                        }
//                    }
//                    catch (IOException e)
//                    {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        });
//        t.setDaemon(true);
//        t.start();
        
        client.put("/home/ubuntu/hi.txt", "Hi node!");

        client.disconnect();

        // JSch jsch = new JSch();
        // jsch.addIdentity(loginCredentials.getPrivateKey());
        //
        // Session session = jsch.getSession(loginCredentials.getUser(), hostAndPort.getHostText());
        //
        // Properties config = new Properties();
        // config.put("StrictHostKeyChecking", "no");
        //
        // session.setConfig(config);
        // session.connect();
        //
        // Channel shell = session.openChannel("shell");
        // shell.setInputStream(System.in);
        // shell.setOutputStream(System.out);
        // shell.connect(0);

    }
 
开发者ID:alessandroleite,项目名称:dohko,代码行数:64,代码来源:SshClientExample.java



注:本文中的com.jcraft.jsch.agentproxy.AgentProxyException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CryptoConfig类代码示例发布时间:2022-05-22
下一篇:
Java RequiresHttpAction类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap