1 /**
2 * Copyright 2010-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.common.util;
17
18
19 public class SshUtilsTest2 {
20 /*
21 @Test
22 public void test() {
23 try {
24 String userHome = System.getProperty("user.home");
25 File localFile = new File(userHome + "/Downloads/jarc.zip");
26 String base = userHome + "/.ssh/";
27 List<String> privateKeys = Arrays.asList(base + "id_rsa", base + "kr-key.pem", base + "ks-key.pem");
28 String remoteDir = "/root/foo/joe/x";
29 String username = "root";
30 String host = "ci.fn.kuali.org";
31 int port = 22;
32 Properties config = new Properties();
33 config.setProperty("StrictHostKeyChecking", "no");
34 JSch jsch = new JSch();
35 for (String privateKey : privateKeys) {
36 jsch.addIdentity(privateKey);
37 }
38 Session session = jsch.getSession(username, host, port);
39 session.setConfig(config);
40 session.connect();
41 ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
42 channel.connect();
43 String s = channel.pwd();
44 System.out.println(s);
45 channel.mkdir(remoteDir);
46 channel.cd(remoteDir);
47 String filename = localFile.getName();
48 InputStream in = new FileInputStream(localFile);
49 channel.put(in, filename);
50 channel.disconnect();
51 session.disconnect();
52 } catch (Exception e) {
53 e.printStackTrace();
54 }
55 }
56 */
57 }