I need to connect with the sftp host without password. For that I have passed null as password and "" empty string as password. In both case i got below exception. But using putty I am able to connect with SFTP host without password . Kindly guide me connect with SFTP.
public void login(String hostName, int port, String userName, String password)
throws Exception
{
try {
SSHFTPClient m_SFTP = new SSHFTPClient();
m_SFTP.setRemoteHost(hostName);
m_SFTP.setRemotePort(port);
m_SFTP.setAuthentication(userName, null);
System.out.println("Turning off server validation");
m_SFTP.getValidator().setHostValidationEnabled(false);
m_SFTP.connect();
System.out.println("FTPProcessHandlerSFTFact login :'" + m_SFTP.connected() +"'");
} catch (Exception e) {
setReply("4", e.getMessage());
throw e;
}
}
Exception :
com.enterprisedt.net.ftp.ssh.SSHFTPException: Could not authenticate SSH client: FAILED
at com.enterprisedt.net.ftp.ssh.SCPClient.connectSSH(SCPClient.java:1152) ~[edtftpj-pro.jar:na]
at com.enterprisedt.net.ftp.ssh.SSHFTPClient.connect(SSHFTPClient.java:920) ~[edtftpj-pro.jar:na]