ok, i have resolved this myself, i have added those lines to
commons-vfs/src/java/org/apache/commons/vfs/provider/sftp/SftpFileSystem.java
====================== session.setPassword( rootName.getPassword() ); java.util.Properties config=new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); ======================
(so i don't need to edit my .ssh/known_hosts)
The problem is that there is no way to configure ssh properties from outside. Commons-vfs is missing a way to transfer properties to its 'file system' plugins.
But still the sftp task fails, now with a 'Permission denied'.
The same copy task runs fine with the bsch sample ScpTo.java.
I have compared the VFS code to the sample code from 'bsch'. It appears that VFS uses
channel = (ChannelSftp)session.openChannel( "sftp" );
instead of
channel = (ChannelExec)session.openChannel( "exec" );
My question now is:
Has anybody ever used the commons-vfs SFTP code, or in other words:
Is it my configuration problem or did the VFS-SFTP code never work properly?
thanks
Marcel
Hi,
i have downloaded commons-vfs-20031106.tar.gz and compiled in on Linux 2.4.21 with SUN JDK 1.4.1.
I need to use the scp feature with 'sftp'. Is there any tutorial how to setup everything?
Here is my problem:
/opt/commons-vfs> java org.apache.commons.vfs.example.Shell
> cp LICENSE.txt ftp://mrf:[EMAIL PROTECTED]/LICENSE.txt
(normal copy works fine!)
> cp LICENSE.txt sftp://mrf:[EMAIL PROTECTED]/LICENSE.txt
com.jcraft.jsch.JSchException: UnknownHostKey
at com.jcraft.jsch.Session.checkHost(Unknown Source)
at com.jcraft.jsch.Session.connect(Unknown Source)
at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:120)
at org.apache.commons.vfs.provider.sftp.SftpFileObject.statSelf(SftpFileObject.java:138)
at org.apache.commons.vfs.provider.sftp.SftpFileObject.doGetType(SftpFileObject.java:104)
at org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:919)
at org.apache.commons.vfs.provider.AbstractFileObject.exists(AbstractFileObject.java:372)
at org.apache.commons.vfs.example.Shell.cp(Shell.java:215)
at org.apache.commons.vfs.example.Shell.handleCommand(Shell.java:151)
at org.apache.commons.vfs.example.Shell.go(Shell.java:127)
at org.apache.commons.vfs.example.Shell.main(Shell.java:90)
Command failed:
org.apache.commons.vfs.FileSystemException: Could not determine the type of file "sftp://mrf:[EMAIL PROTECTED]/LICENSE.txt".
at org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:931)
at org.apache.commons.vfs.provider.AbstractFileObject.exists(AbstractFileObject.java:372)
at org.apache.commons.vfs.example.Shell.cp(Shell.java:215)
at org.apache.commons.vfs.example.Shell.handleCommand(Shell.java:151)
at org.apache.commons.vfs.example.Shell.go(Shell.java:127)
at org.apache.commons.vfs.example.Shell.main(Shell.java:90)
Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://mrf:[EMAIL PROTECTED]/".
at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:140)
at org.apache.commons.vfs.provider.sftp.SftpFileObject.statSelf(SftpFileObject.java:138)
at org.apache.commons.vfs.provider.sftp.SftpFileObject.doGetType(SftpFileObject.java:104)
at org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject.java:919)
... 5 more
Caused by: com.jcraft.jsch.JSchException: UnknownHostKey
at com.jcraft.jsch.Session.checkHost(Unknown Source)
at com.jcraft.jsch.Session.connect(Unknown Source)
at org.apache.commons.vfs.provider.sftp.SftpFileSystem.getChannel(SftpFileSystem.java:120)
... 8 more >
Any idea about the "UnknownHostKey"?
thanks,
Marcel
PS: The pure jsch-0.1.8/examples works fine:
java ScpTo XY [EMAIL PROTECTED]:XY
PPS: Does VFS work with http://www.sshtools.com/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]