Jsch et serveur local Filezilla
Bonjour,
Je cherche à tester le transfert de fichiers d'un répertoire local à un autre via SFTP en utilisant la librairie Java Jsch et le serveur local FileZilla.
Après configuration de Filezilla (nouveau serveur, utilisateur, password), et le passage des mêmes paramètres à mon programme Java, j'arrive à me connecter au serveur mais je n'arrive pas à me logger.
Voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| public ChannelSftp connectSFTP() throws JSchException
{
final JSch jsch = new JSch();
this.sessionSftp = jsch.getSession(this.workstation.getLogin(),
this.workstation.getHostName(),
this.workstation.getPort());
this.sessionSftp.setUserInfo(new UserInfo()
{
public String getPassphrase()
{
return null;
}// end method
public String getPassword()
{
return null;
}// end method
public boolean promptPassphrase(final String string)
{
return false;
}// end method
public boolean promptPassword(final String string)
{
return false;
}// end method
public boolean promptYesNo(final String string)
{
return true;
}// end method
public void showMessage(final String string)
{
System.out.println(string);
}// end method
});
this.sessionSftp.setPassword(this.workstation.getPassword());
this.sessionSftp.connect();
final Channel channel = this.sessionSftp.openChannel("sftp");
channel.connect();
final ChannelSftp channelSftp = (ChannelSftp) channel;
return channelSftp;
}// end method |
Ce programme se bloque au connect() et lève une exception lorsque le time out de Filezilla ferme la connexion.
Filezilla affiche le message suivant : "(not logged in) (127.0.0.1)> Connected, sending welcome message...".
Je pense qu'il y a un problème local, puisque ce code marche lorsque je me connecte à un serveur distant Linux.
Merci par avance pour votre aide,
Eva