嘗試使用嵌入在Java中的Apache Mina SSHD爲用戶設置主目錄。Apache Mina SSHD 1.0.0設置用戶目錄和映射
兩種溶液以1.0 IN-
How to Set Root Directory in Apache Mina Sshd Server in Java
How to override getVirtualUserDir() in Apache Mina sshd-core version 0.14.0
棄用在0.14.0以下工作得很好:
sshd.setFileSystemFactory(new NativeFileSystemFactory() {
@Override
public FileSystemView createFileSystem(final Session session) {
HashMap<String,String> map = new HashMap<String,String>();
map.put("/", "/Users/someone/Documents");
return new NativeFileSystemView(session.getUsername(), map, "/");
};
});
這是據我得到:
sshd.setFileSystemFactory(new NativeFileSystemFactory() {
@Override
public FileSystem createFileSystem(Session session) {
// What should I do here?
return super.createFileSystem(session);
}
});