简体   繁体   English

使用带有 Putty 私钥的 Runtime.exec 连接到远程 linux 系统

[英]To connect to remote linux system using Runtime.exec with Putty private key

I wanna programmatically (using Java's Runtime.exec) open Putty on my system and connect to a remote linux system.我想以编程方式(使用 Java 的 Runtime.exec)在我的系统上打开 Putty 并连接到远程 linux 系统。 Is there any syntax to pass Putty private key to the method runtime.exec and connect successfully.是否有任何语法可以将 Putty 私钥传递给方法 runtime.exec 并成功连接。 I am getting "Access Denied" error on the remote system if I just pass the username and pass-phrase and try to connect.如果我只是传递用户名和密码短语并尝试连接,我会在远程系统上收到“拒绝访问”错误。

I am assuming by your comments that you are trying to actually run some commands on a linux server, like我根据您的评论假设您正在尝试在 linux 服务器上实际运行一些命令,例如

find /some-directory/ -type f -ecec grep -Hnw this-word {} ";"

via bash or other shell as opposed to rcp.通过 bash 或其他 shell,而不是 rcp。

If yes then stop using putty, that is an interactive client for you to login to a remote server and interact with the connected shell.如果是,则停止使用 putty,这是一个交互式客户端,您可以登录到远程服务器并与连接的 shell 进行交互。

I would suggest that you would be far better off using something like jssh, assuming it is still a current library.我建议你最好使用像 jssh 这样的东西,假设它仍然是一个当前的库。

With that you get fine control of the interaction flow with the remote server and iirc it supports private/public keys.有了它,您就可以很好地控制与远程服务器的交互流程,而 iirc 它支持私钥/公钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM