No need to confirm fingerprint, no need to type password in keyboard, just put password as command-line argument to execute command via SSH, suit for using in scripts.
Written in Java, Run under both Windows and Linux.
By now only those output-only commands are supported, such as ls, df, vmstat.
- Install Java 11 or above.
- Download, unzip from the Releases page.
- Run in command prompt, arguments are same as the standard ssh command, plus --password option, like
ssh-execute --password OpenSesame alibaba@192.168.0.1 "ls -l --color /tmp"
or
ssh-execute -l alibaba --password OpenSesame -p 22 192.168.0.1 "ls -l --color /tmp"
Specify connection timeout in seconds:
ssh-execute -o ConnectTimeout=10 --password OpenSesame alibaba@192.168.0.1 "ls -l --color /tmp"
Specify command timeout in seconds:
ssh-execute --command-timeout 10 --password OpenSesame alibaba@192.168.0.1 "ls -l --color /tmp"
Specify connection timeout in seconds with a new option name to keep the style:
ssh-execute --connect-timeout 10 --password OpenSesame alibaba@192.168.0.1 "ls -l --color /tmp"
ssh-execute --help
-
In Maven pom.xml:
See Packages page. -
In Java code:
import cn.nhcqc.sshex.SSHExecute;
var config = new SSHExecute.Config ();
// set config field values
int exit = new SSHExecute ().run (config);
LGPL-2.1 (GNU Lesser General Public License).
See file LICENSE for details.
- Install Apache Maven 3
- Run
mvn package
- In the target folder, those listed below are for standalone run:
- *.bat
- *.java
- *.ini
- lib
(Dependencies)
examples
https://github.com/hierynomus/sshj/tree/master/examples/src/main/java/net/schmizz/sshj/examples
com.hierynomus:sshj:0.33.0
https://search.maven.org/artifact/com.hierynomus/sshj
<dependency>
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
<version>0.33.0</version>
</dependency>
Using
https://commons.apache.org/proper/commons-cli/usage.html
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.5.0</version>
</dependency>
user manual
https://www.slf4j.org/manual.html
config file
http://www.javapractices.com/topic/TopicAction.do?Id=143