我想用java程序连接到unix服务器。
我正在做以下事情,但它抛出一些授权失败错误:
Error: Connect fails with the following exception: com.jcraft.jsch.JSchException: Auth fail码:
public class ExecuteUnix {
public static void main(String[] args) throws TaskExecFailException {
SSHExec ssh = null;
SSHExec.setOption(IOptionName.HALT_ON_FAILURE, true);
SSHExec.setOption(IOptionName.SSH_PORT_NUMBER,3105);
SSHExec.setOption(IOptionName.INTEVAL_TIME_BETWEEN_TASKS, 100000l);
SSHExec.setOption(IOptionName.TIMEOUT, 36000l);
System.out.println("Hello");
// Initialize a ConnBean object, parameter list is ip, username, password
ConnBean cb = new ConnBean("HostName","Username","Password");
try {
SSHExec.showEnvConfig();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Put the ConnBean instance as parameter for SSHExec static method getInstance(ConnBean) to retrieve a singleton SSHExec instance
ssh = SSHExec.getInstance(cb);
// Connect to server ssh.connect();
ssh.connect();
System.out.println("Connected");
ssh.disconnect();
System.out.println("DisConnected");
}
}你能告诉我究竟是什么吗?