4

Using Java is possible to mount a remote disk via 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.

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. Unfortunately I can not find anything ....

I use Java because it may be fine for both Windows and Linux.

Ideas?

user2263764
  • 341
  • 5
  • 21
  • It's possible to open a SSH shell to a remote machine and execute commands, which would allow you to execute a mount command with the context of the remote machine. Have a look for jsch for examples – MadProgrammer Jul 19 '14 at 22:10
  • Define "mount the disk"? You could write to the remote system, but implementing an OS level file-system bridge from Java would not be my first choice. – Elliott Frisch Jul 19 '14 at 22:13
  • probably he/she's looking for something like sshfs support for apache commons vsf. Interesting question, indeed. – Leo Jul 19 '14 at 22:16
  • @MadProgrammer: already tested with jsch, but does not mount the remote disk, you can send the commands as an ftp session. Elliott Frisch: yeah, right, mount the disk to be able to be accessed for read / write. Exactly as the programs mentioned above. If nothing exists for Java. you know some library for C # / VB.NET? – user2263764 Jul 20 '14 at 07:57

1 Answers1

2

Take a look at Sshfs helps mount a remote file system hosted via a ssh server onto a local machine

Here is a Sshfs Java Implementation

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.

Madaditya
  • 143
  • 2
  • 10