0

I am creating java program using jcraft library to connect remote machine and my code is:-

 String host = "192.168.1.123";         

        JSch jsch = new JSch();
        Session session = jsch.getSession(host);
        Properties config = new Properties();
        config.put("StrictHostKeyChecking", "no");
        session.setConfig(config);
        session.connect();

When i execute my program it was giving following error

com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:519)
at com.jcraft.jsch.Session.connect(Session.java:183)

But if i set password in session parameter then it was working

session.setPassword("xxxxx");

But i don't want set password in session objects .Is there any option to connect remote machine without password.

santosh
  • 435
  • 1
  • 7
  • 24
  • check for `whitespace` in property file – Ravi Jan 04 '18 at 09:28
  • What do you mean by *"connect without password"*? Do you have any other method of authentication set up? If you have a generic question about possible ways of authenticating in SSH, you are on a wrong place. Ask at [su] (though this has probably been discussed there thousand times already). If you already know, that you want to implement, be more specific. – Martin Prikryl Jan 04 '18 at 09:47

0 Answers0