简体   繁体   中英

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. Is there any syntax to pass Putty private key to the method runtime.exec and connect successfully. 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

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

via bash or other shell as opposed to 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.

I would suggest that you would be far better off using something like jssh, assuming it is still a current library.

With that you get fine control of the interaction flow with the remote server and iirc it supports private/public keys.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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