Package net.schmizz.sshj

Examples of net.schmizz.sshj.SSHClient.connect()


  private void exec(String command) throws IOException {
    SSHClient ssh = new SSHClient();
    ssh.loadKnownHosts();
    ssh.addHostKeyVerifier(new NullHostKeyVerifier());
    ssh.connect(vmName);
    ssh.authPassword(vmUser, vmPwd);

    final Session session = ssh.startSession();
    try {
      final Command cmd = session.exec(command);
View Full Code Here


                    try {
                        logger.info("connecting to {}", sshAddress.address);

                        SSHClient ssh = new SSHClient();
                        ssh.loadKnownHosts(new File(SystemUtils.getUserHome(), ".ssh/known_hosts"));
                        ssh.connect(sshAddress.address);
                        ssh.authPassword(sshAddress.username, sshAddress.password);

                        return ssh;
                    } catch (Exception e) {
                        final String fingerprint = StringUtils.substringBetween(
View Full Code Here

                        SSHClient ssh = new SSHClient();

                        ssh.loadKnownHosts(new File(SystemUtils.getUserHome(), ".ssh/known_hosts"));
                        ssh.addHostKeyVerifier(fingerprint);
                        ssh.connect(sshAddress.address);
                        ssh.authPassword(sshAddress.username, sshAddress.password);

                        return ssh;
                    }
                }
View Full Code Here

            throws IOException {
        SSHClient ssh = new SSHClient();

        ssh.loadKnownHosts();

        ssh.connect("localhost");
        try {

            ssh.authPublickey(System.getProperty("user.name"));

            /*
 
View Full Code Here

    public static void main(String[] args)
            throws IOException, ClassNotFoundException {
        SSHClient ssh = new SSHClient();
        ssh.loadKnownHosts();
        ssh.connect("localhost");
        try {
            ssh.authPublickey(System.getProperty("user.name"));

            // Present here to demo algorithm renegotiation - could have just put this before connect()
            // Make sure JZlib is in classpath for this to work
View Full Code Here

    public static void main(String... args)
            throws IOException {
        final SSHClient ssh = new SSHClient();
        ssh.loadKnownHosts();

        ssh.connect("localhost");
        try {
            ssh.authPublickey(System.getProperty("user.name"));
            final Session session = ssh.startSession();
            try {
                final Command cmd = session.exec("ping -c 1 google.com");
View Full Code Here

    public static void main(String[] args)
            throws IOException {
        SSHClient ssh = new SSHClient();
        // ssh.useCompression(); // Can lead to significant speedup (needs JZlib in classpath)
        ssh.loadKnownHosts();
        ssh.connect("localhost");
        try {
            ssh.authPublickey(System.getProperty("user.name"));
            ssh.newSCPFileTransfer().download("test_file", new FileSystemFile("/tmp/"));
        } finally {
            ssh.disconnect();
View Full Code Here

    public static void main(String... args)
            throws IOException {
        SSHClient client = new SSHClient();
        client.loadKnownHosts();

        client.connect("localhost");
        try {

            client.authPublickey(System.getProperty("user.name"));

            /*
 
View Full Code Here

        * NOTE: Forwarding incoming X connections to localhost:6000 only works if X is started without the
        * "-nolisten tcp" option (this is usually not the default for good reason)
        */
        ssh.registerX11Forwarder(new SocketForwardingConnectListener(new InetSocketAddress("localhost", 6000)));

        ssh.connect("localhost");
        try {

            ssh.authPublickey(System.getProperty("user.name"));

            Session sess = ssh.startSession();
View Full Code Here

    public static void main(String[] args)
            throws IOException {
        final SSHClient ssh = new SSHClient();
        ssh.loadKnownHosts();
        ssh.connect("localhost");
        try {
            ssh.authPublickey(System.getProperty("user.name"));
            final String src = System.getProperty("user.home") + File.separator + "test_file";
            final SFTPClient sftp = ssh.newSFTPClient();
            try {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.