When calling sshpass from Java with shell etc., it seems that it is necessary to have a path.

ssh -i /Users/uramoty/.ssh/id_rsa IP or URL of the host you want to log in to

If you execute from the terminal, you can log in safely, but with Java in between,

    String[] cmd = {				 
            "sshpass",
			"-p",

"password", "ssh", "-r", "-o", "Login host GIP" }; doShell SampleRunTime = new doShell(); try { SampleRunTime.execCmd(cmd); } catch (Exception e) { e.printStackTrace(); }

For some reason, an error occurs. which sshpass then / usr / local / bin / sshpass So "Sshpass", in the above sample, "/ usr / local / bin / sshpass", Please try. If that doesn't work, use the sample "sshpass", above.

The actual path of / usr / local / bin / ** sshpass **. "/usr/local/Cellar/sshpass/1.05/bin/sshpass",

To.

Recommended Posts

When calling sshpass from Java with shell etc., it seems that it is necessary to have a path.
Try calling Watson NLU that seems to support Japanese from the Java SDK
When is it said that you can use try with a Swift error?
Find a value that is convenient to have a method and make it a ValueObject
I tried to make a program that searches for the target class from the process that is overloaded with Java
What to do when is invalid because it does not start with a'-'
[Java] When putting a character string in the case of a switch statement, it is necessary to make it a constant expression
File path is not recognized when executing an external command from a Java application
Java learning_Behavior when there is a method with the same name as a field with the same name in two classes that have an inheritance relationship
A story that made it convenient with Kotlin that it is troublesome to execute animation continuously on Android
Convert Excel to Blob with java, save it, read it from DB and output it as a file!
A story that I struggled to challenge a competition professional with Java
Is it possible to automatically generate Getters / Setters with Java Interface?
[Note] Java: Is it necessary to override equals for equality judgment?
How to identify the path that is easy to make a mistake
What I often do when I have trouble naming with Java (etc.)
[WSL] Solution for the phenomenon that 404 is displayed when trying to insert Java with apt (personal memo)
A standalone Java app that sends logs to CloudWatch Logs with slf4j / logback
A shell script that builds a Docker image and pushes it to ECR
[Java small story] Monitor when a value is added to the List
Hanashi stumbled a little on path trying to study Java with VScode
When calling println etc. from an external Java class file in Processing
A story that suffered from a space that does not disappear even if trimmed with Java The cause is BOM