使用 ssh 和 sftp 通过 Java 连接到 Unix [RSA SecuerID 令牌]

问题描述:

我需要使用 Java 通过 SSHSFTP 协议连接到 Unix 服务器,并执行特定命令并进行文件传输.但是在 Unix 上启用了 RSA 令牌身份验证.所以我需要在运行时获取当前的 RSA 令牌密码以及用户密码.那么如何完成这项工作通过Java?有没有针对此的 Java API?

I need to connect to Unix Server using Java via SSH and SFTP protocol and execute specific commands and do File Transfers also. But there is RSA token authentication is enabled on Unix. So I need to get the current RSA token password at run time also along with User's Password. So how to get this done via Java? Is there any Java API for this?

仅供参考,使用 putty 的 Unix 登录步骤:

FYI, Unix Login steps using putty :

  1. 使用服务器 IP 连接.
  2. 列表项
  3. 提供用户名.
  4. 输入密码
  5. 提供 6 位 SecurID 生成的编号.

这听起来像是键盘交互式身份验证.在这种身份验证机制中,服务器向用户提出一个问题,用户必须对此做出回应.任何数量的问题都是可能的,它们的顺序由服务器定义.

This sounds like keyboard-interactive authentication. In this authentication mechanism the server asks user a question, to which the user must respond. Any number of questions is possible and their order is defined by the server.

许多服务器都使用键盘交互身份验证,但通常只要求输入密码,因此大多数声称支持此身份验证方法的软件只会将密码作为答案,仅此而已.

Keyboard-interactive authentication is used by many servers, but it's usually reduced to asking for a password, so most software which claims support for this authentication method will just put a password as the answer and that's all.

我不知道免费的 Java 库是否支持带有多个问题的键盘交互身份验证.我们的 SecureBlackbox 类有一个将问题传递给应用程序的事件,应用程序可以要么自己提供答案,要么要求人工操作员提供答案.

I don't know if free Java libraries support keyboard-interactive authentication with multiple questions. Our SecureBlackbox classes have an event which passes questions to the application, and the application can either provide an answer itself or ask the human operator to provide the answer.