我使用的Apache 米娜SSHD API启动在java.In SFTP客户端本地SFTP服务器我使用Jcraft jsch API创建SFTP我client.I成功启动服务器。问题是我想编写一些单元测试用例来检查客户端是否可以将某些文件放入服务器的根目录。目前我的SFTP服务器没有任何根目录。所以我想知道是否有任何方法来设置服务器的根目录。如何设置根目录中的Apache米娜sshd服务器在Java中
例如:C:\ sftp如何将此路径设置为我的服务器根目录。因此,客户端每次连接服务器时都可以读取和写入文件。谢谢。
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
}
的可能重复[如何开始编程在Java SFTP服务器(http://stackoverflow.com/questions/29531342/how-to-start -sftp-server-programming-in-java) – 2015-04-09 06:34:24
@DanielNewtown你好,我知道这是很久以前的事情了..可以请你在链接里重新发布那篇文章吗?当我们说话时它现在返回404。在此先感谢 – 2016-06-02 12:24:13