[英]How to write SFTP client using Apache MINA library
我嘗試使用 Apache MINA 庫為 SFTP 客戶端查找 Java 代碼,但找不到。
有人可以告訴我如何使用 Apache MINA 庫編寫一個簡單的基於密碼身份驗證的 SFTP 客戶端。
https://mina.apache.org/sshd-project/apidocs/org/apache/sshd/client/subsystem/sftp/SftpClient.html
基於apache-sshd-2.2.0-src
包根目錄README.md
中的示例:
SshClient client = SshClient.setupDefaultClient();
// override any default configuration...
client.setSomeConfiguration(...);
client.setOtherConfiguration(...);
client.start();
try (ClientSession session = client.connect(user, host, port).verify(timeout).getSession()) {
session.addPasswordIdentity(password);
session.auth.verify(timeout);
// User-specific factory
try (SftpClient sftp = DefaultSftpClientFactory.INSTANCE.createSftpClient(session)) {
// use sftp here
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.