Io uso Apache Mina server SSHd API per avviare un server SFTP locale client SFTP java.In io uso Jcraft jsch API di creare il mio SFTP client.I avviare correttamente un server. Il problema è che voglio scrivere alcuni casi di test unitari per verificare se il client può inserire alcuni file nella directory principale del server. Attualmente il mio server SFTP non ha alcuna directory root. Vorrei sapere che esiste un approccio per impostare la directory root del server.Come impostare la directory radice in Apache Mina server SSHd Server in Java
Esempio: C: \ sftp Come posso impostare questo percorso come directory principale del server. Quindi il client può leggere e scrivere file ad esso ogni volta che si connette al server. Grazie
public class SftpServerStarter {
\t
\t private SshServer sshd;
\t private final static Logger logger = LoggerFactory.getLogger(SftpServerStarter.class);
\t
\t public void start(){
\t \t
\t \t
\t \t sshd = SshServer.setUpDefaultServer();
\t \t sshd.setPort(22);
\t \t sshd.setHost("localhost");
\t \t
sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());
sshd.setPublickeyAuthenticator(new MyPublickeyAuthenticator());
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
sshd.setCommandFactory(new ScpCommandFactory());
try {
\t logger.info("Starting ...");
\t \t \t sshd.start();
\t \t \t logger.info("Started");
\t \t } catch (IOException e) {
\t \t \t // TODO Auto-generated catch block
\t \t \t e.printStackTrace();
\t \t \t logger.info("Can not Start Server");
\t \t }
\t }
\t
}
possibile duplicato di [Come avviare server SFTP di programmazione in Java] (http://stackoverflow.com/questions/29531342/how-to-start -sftp-server-programmaticamente-in-java) –
@DanielNewtown Ciao amico, so che è da molto tempo indietro ... potresti per favore ri-postare quell'articolo nel link? restituisce un 404 ora mentre parliamo. Grazie in anticipo –