Skip to content

SSH execute command with password argument, without fingerprint confirm. Run under both Windows and Linux.

License

Notifications You must be signed in to change notification settings

ActiveVolcano/ssh-execute-with-password

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SSH execute command with password

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.

Usage as standalone run

Basic options similar to the standard ssh client

  1. Install Java 11 or above.
  2. Download, unzip from the Releases page.
  3. 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"

Extra options

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"

Full command-line usage

ssh-execute --help

Usage as Java package

  • 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);

License

LGPL-2.1 (GNU Lesser General Public License).

See file LICENSE for details.

How to compile

  1. Install Apache Maven 3
  2. Run
mvn package
  1. In the target folder, those listed below are for standalone run:
    • *.bat
    • *.java
    • *.ini
    • lib

Development Notes

(Dependencies)

sshj

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>

Apache Commons CLI

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>

SLF4J

user manual
https://www.slf4j.org/manual.html

java.util.logging

config file
http://www.javapractices.com/topic/TopicAction.do?Id=143

About

SSH execute command with password argument, without fingerprint confirm. Run under both Windows and Linux.

Topics

Resources

License

Stars

Watchers

Forks

Packages