且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Windows 上使用 java 执行 linux 命令?

更新时间:2022-05-20 07:52:24

找了好久,终于找到有用的信息了.请按照链接如何运行 SSH 命令在使用 Java 的远程系统上?"

After long hours, I finally found useful information. please follow link "How do I run SSH commands on remote system using Java?"

也使用来自http://www.ganymed.ethz.ch/ssh2/"链接.它是任何人在 windows 环境下从 java 代码执行 ssh 命令所需的 jar.还有其他方法.而且大多数 jars 我没有发现它们有用,特别是当你想自动化用户身份验证以访问 linux 环境时.

Also use jar from "http://www.ganymed.ethz.ch/ssh2/" the link. It is the jar required for any person to execute ssh commands from java code in windows environment. There are other ways too. And most jars I didn't find them useful, especially when you want to automate user authentication to access linux environment.

注意,直接传递密码(ssh 密码)是不合适的做事方式.许多专家在其他几个线程中提出了建议.但这个简单的解决方案适用于不关心安全性的人.

Note, passing directly the password (ssh password) is not appropriate way of doing things.And many experts suggested in few other threads.But this simple solution works for someone who is not concerned about security.