从 Windows 计算机远程运行 Linux 上的进程

发布于 2024-08-05 13:19:35 字数 89 浏览 2 评论 0原文

我希望能够从 Windows 计算机上运行的 JAVA 应用程序远程运行 Linux 计算机上存在的进程。最好的方法是什么?或者可能对我有帮助的在线资源?非常感谢。

I would like to be able to run a process that exists on a Linux machine remotely from a JAVA application running on a Windows machine. What is the best way to do this? Or an online resource that might be of help to me? Thanks very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

清风不识月 2024-08-12 13:19:35

您可以使用许多 Java SSH 客户端库中的任何一个,例如 javassh,只要 Linux机器运行 sshd (并且防火墙都设置为让 ssh 流量通过),这很可能是这种情况。有许多可能的方法来配置 ssh 身份验证,基本上可以归结为在网络上(安全地)发送密码,或使用公钥/私钥对(RSA 或 DSA)——后者通常更可取,但您需要请向系统和网络管理员咨询此问题...这实际上并不是软件开发问题,而是与系统管理和安全相关的问题。

You could use any of the many Java SSH client libraries, such as javassh, as long as the Linux machine runs an sshd (and the firewalls are all set to let ssh traffic through), which is likely to be the case. There are many possible ways to configure ssh authentication, basically boiling down to either sending password (securely) on the net, or using public/private key pairs (RSA or DSA) -- the latter is generally preferable, but you'll need to check with system and network administrators about this issue... it's not really a software development issue, but rather one related to system administration and security.

静水深流 2024-08-12 13:19:35

简而言之,使用 ssh 客户端。

选项 1:在 Cygwin 中安装 openssh 软件包。

选项 2:使用 Putty

在任何一种情况下,您都可以设置密钥对以允许自动(非密码)身份验证。

In short, use an ssh client.

Option 1: Install openssh package in Cygwin.

Option 2: Use Putty.

In either case, you can setup a keypair to allow for automatic (non-password) authentication.

请爱~陌生人 2024-08-12 13:19:35
  1. 将进程公开为 Linux 计算机上的 [即发即忘] Web 服务。
  2. 从 Windows 机器上调用它。
  1. Expose the process as a [fire and forget] web service on the Linux machine.
  2. Call it from the windows machine.
雪落纷纷 2024-08-12 13:19:35

您还可以创建一种客户端/服务器架构。您的 Java 客户端将向您的 Java 服务器(~ webservice)发送一条命令,该命令将执行所需的进程。
但显然,这取决于您的目标。
您需要以安全的方式做到这一点吗?
是通过互联网还是在本地网络内?
最后,该进程是 Java 进程吗?

You can also make a kind of client/server architecture. Your Java client will send a command to your Java server (~ webservice), that will execute the desired process.
But obviously, it depends on your aims.
Do you need to do that in a secure way?
Is it through the internet or inside a local network?
And finally, is the process a Java process?

绝情姑娘 2024-08-12 13:19:35

您可以使用 ssh 命令登录系统
例子..

     String[] cm = {
                   "ssh",
                   "username@hostIP" ,
                   "your command"

                   };

     try
      {
       Process q=  Runtime.getRuntime().exec(cm);
       q.waitFor();
      }
    catch(Exception e) {}

You can use ssh command to login into a sytem
example..

     String[] cm = {
                   "ssh",
                   "username@hostIP" ,
                   "your command"

                   };

     try
      {
       Process q=  Runtime.getRuntime().exec(cm);
       q.waitFor();
      }
    catch(Exception e) {}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文