THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
No Format |
---|
((DefaultFileSystemManager) fsManager).close(); |
How can I connect to an SFTP server even if there is no entry in known_hosts?
JSch, the library that provides VFS with SFTP functionality, checks that the host one tries connecting to is a known host, i.e. has an entry in the file $HOME/.ssh/known_hosts. By default, connections to unkown hosts are rejected by throwing an exception. You can change this behaviour by specifying the strict host key checking option:
No Format |
---|
FileSystemOptions opts = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
FileSystemManager fsManager = VFS.getManager();
FileObject foo = fsManager.resolveFile("sftp://login:password@host/foo.bar", opts);
// Do some stuff
foo.close();
((DefaultFileSystemManager) fsManager).close();
|