简体   繁体   English

通过SSH使用Java挂载远程磁盘

[英]Mount remote disk with Java via SSH

Using Java is possible to mount a remote disk via SSH? 使用Java可以通过SSH挂载远程磁盘吗? I saw that exist for Windows systems such as Dokan, win-SSH-FS or anything, but I would need to be able to map the remote disk through Java. 我看到存在用于Windows系统,如Dokan,win-SSH-FS或其他任何东西,但我需要能够通过Java映射远程磁盘。

I have already completed part of the application in Java but as the last thing I need that the login process of my application perform also mount the disk. 我已经用Java完成了部分应用程序,但最后我需要的是我的应用程序执行的登录过程也会挂载磁盘。 Unfortunately I can not find anything .... 不幸的是我找不到任何东西....

I use Java because it may be fine for both Windows and Linux. 我使用Java因为它可能适用于Windows和Linux。

Ideas? 想法?

Take a look at Sshfs helps mount a remote file system hosted via a ssh server onto a local machine 看看Sshfs有助于将通过ssh服务器托管的远程文件系统安装到本地计算机上

Here is a Sshfs Java Implementation 这是一个Sshfs Java实现

Map<String, Object> environment = new HashMap<String, Object>();
environment.put( "defaultSessionFactory", defaultSessionFactory );
environment.put( "watchservice.inotify", true );
uri = new URI( scheme + "://" + username + "@" + hostname + ":" + port + sshPath );
FileSystem fileSystem = FileSystems.newFileSystem( uri, environment );

and then you can treat the files as local files and operate on them. 然后您可以将文件视为本地文件并对其进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM