【发布时间】:2016-04-29 18:15:42
【问题描述】:
我正在尝试使用 Java 的 Ganymed 将文件从 Windows 服务器(安装了 openSSH / Cygwin)SCP 到 Mac。我以编程方式获取当前目录的路径,但由于某种原因,它说找不到本地目录。这绝对是正确的路径,所以我不知道发生了什么。
Connection conn;
String hostname = "10.10.1.2";
String username = "myuser";
String password = "mypass";
String localDir = System.getProperty("user.dir");
String remoteFile = "/path/to/the/file.txt";
Connection conn = new Connection(hostname);
conn.connect();
conn.authenticateWithPassword(username, password);
SCPClient scp = conn.createSCPClient();
scp.put(remoteFile, 2815, localDir, "0644");
conn.close();
因为我使用的是 .getProperty 方法,所以我知道路径是对的。此外,我有单独的方法可以 ssh 到 Windows 机器并启动/停止服务,所以我知道凭据是正确的。那么为什么这不起作用呢?谢谢!
【问题讨论】: