Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to SSHByPassword using the given code #40

Open
lum0s opened this issue Dec 31, 2015 · 4 comments
Open

Unable to SSHByPassword using the given code #40

lum0s opened this issue Dec 31, 2015 · 4 comments

Comments

@lum0s
Copy link

lum0s commented Dec 31, 2015

Hi
I have been trying to get this code working for the past 5-6 hrs but I have had no success so far. Kindly help me resolve this issue. I am working on eclipse and I want to ssh into my raspberry pi using SSHByPassword. I downloaded the jcabi-ssh-1.5-jar-with-depencies.jar. Running my code with this gives me the error :

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.io.IOException: com.jcraft.jsch.JSchException: Session.connect: java.net.SocketTimeoutException: Read timed out
at com.jcabi.ssh.SSHByPassword.session(SSHByPassword.java:147)
at com.jcabi.ssh.SSHByPassword.exec(SSHByPassword.java:108)
at com.jcabi.ssh.Shell$Plain.exec(Shell.java:172)
at Hope.main(Hope.java:10)
Caused by: com.jcraft.jsch.JSchException: Session.connect: java.net.SocketTimeoutException: Read timed out
at com.jcraft.jsch.Session.connect(Session.java:558)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.jcabi.ssh.SSHByPassword.session(SSHByPassword.java:144)
... 3 more

--------------------------------------------------------------------------------------------------------------------------------------------------------------------
-> Next I added slf4j-nop-1.7.13.jar to my project reference library. I get the following error now: 

Exception in thread "main" java.io.IOException: com.jcraft.jsch.JSchException: Session.connect: java.net.SocketTimeoutException: Read timed out
at com.jcabi.ssh.SSHByPassword.session(SSHByPassword.java:147)
at com.jcabi.ssh.SSHByPassword.exec(SSHByPassword.java:108)
at com.jcabi.ssh.Shell$Plain.exec(Shell.java:172)
at Hope.main(Hope.java:10)
Caused by: com.jcraft.jsch.JSchException: Session.connect: java.net.SocketTimeoutException: Read timed out
at com.jcraft.jsch.Session.connect(Session.java:558)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.jcabi.ssh.SSHByPassword.session(SSHByPassword.java:144)
... 3 more

---------------------------------------------------------------------------------------------------------------------------------------------------------------------

My code is as follows:

import com.jcabi.ssh.Shell;
import java.io.IOException;
import java.net.UnknownHostException;
import com.jcabi.ssh.SSHByPassword;
import com.jcabi.log.*;

public class Try {
   public static void main(String[] args) throws IOException{
        Shell shell = new SSHByPassword("192.168.1.2", 22, "pi", "abc");
        String stdout = new Shell.Plain(shell).exec("echo 'Hello, world!'");
      }
}
@dmarkov
Copy link

dmarkov commented Jan 4, 2016

@yegor256 please take a look at it and dispatch (see par.21)

@yegor256
Copy link
Member

yegor256 commented Jan 4, 2016

@HackerDm the code looks correct. I suspect, there is not SSHD on port 22 in your Pi. could this be the case?

@lum0s
Copy link
Author

lum0s commented Jan 4, 2016

I can SSH directly using terminal. So SSHD is running on port 22 in my pi.

@ChanosWu
Copy link

I have same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants