001    /**
002     * Copyright 2010-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.common.util;
017    
018    
019    public class SshUtilsTest2 {
020    /*
021            @Test
022            public void test() {
023                    try {
024                            String userHome = System.getProperty("user.home");
025                            File localFile = new File(userHome + "/Downloads/jarc.zip");
026                            String base = userHome + "/.ssh/";
027                            List<String> privateKeys = Arrays.asList(base + "id_rsa", base + "kr-key.pem", base + "ks-key.pem");
028                            String remoteDir = "/root/foo/joe/x";
029                            String username = "root";
030                            String host = "ci.fn.kuali.org";
031                            int port = 22;
032                            Properties config = new Properties();
033                            config.setProperty("StrictHostKeyChecking", "no");
034                            JSch jsch = new JSch();
035                            for (String privateKey : privateKeys) {
036                                    jsch.addIdentity(privateKey);
037                            }
038                            Session session = jsch.getSession(username, host, port);
039                            session.setConfig(config);
040                            session.connect();
041                            ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
042                            channel.connect();
043                            String s = channel.pwd();
044                            System.out.println(s);
045                            channel.mkdir(remoteDir);
046                            channel.cd(remoteDir);
047                            String filename = localFile.getName();
048                            InputStream in = new FileInputStream(localFile);
049                            channel.put(in, filename);
050                            channel.disconnect();
051                            session.disconnect();
052                    } catch (Exception e) {
053                            e.printStackTrace();
054                    }
055            }
056            */
057    }