commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manco <megust...@yahoo.com>
Subject Re: [VFS] Could not connect to SFTP server
Date Wed, 27 Apr 2005 02:52:19 GMT
Update:
 
1. It appears the providers.xml file in the jar  has FTPFileX.

<provider class-name="org.apache.commons.vfs.provider.ftp.FtpFileProvider">
<scheme name="ftp"/>
<if-available class-name="org.apache.commons.net.ftp.FTPFileX"/>
</provider>

 it doesnt seem like this is correct, I un-jarred, changed the value to FTPFile and re-jarred,
 the ftp connection now works again.

2. I dont know much about the known_hosts, but I found the following reference, which I pass
along for the sake of others:

SSH_KNOWN_HOSTS FILE FORMAT
The /etc/ssh/ssh_known_hosts and $HOME/.ssh/known_hosts ...http://linux.about.com/od/commands/l/blcmdl8_sshd.htm
 
3. I put in the following code :
   {
...
              FileSystemOptions opts = new FileSystemOptions();
              SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(
                 opts, "no");
...
                FileObject file = mgr.resolveFile(args[i]);   << still throws error

       ...}
org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://pipe:emeter@linuxserver1/".
 at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:87)
 at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:76)
 at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:61)
 at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:513)
 at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:486)
 at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:456)
 at com.eMeter.vfstest.ShowProperties.main(ShowProperties.java:88)
Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at
"linuxserver1".
 at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:166)
 at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:79)
 ... 6 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 com.jcraft.jsch.Session.connect(Unknown Source)
 at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:162)
 ... 7 more

 
Q: Could this be a problem with the SFTP rejecting my connection? 
 
Thanks,
Manco

Mario Ivankovits wrote:
Hi manco!
>Caused by: com.jcraft.jsch.JSchException: UnknownHostKey
> at com.jcraft.jsch.Session.checkHost(Unknown Source)
> at com.jcraft.jsch.Session.connect(Unknown Source)
> at com.jcraft.jsch.Session.connect(Unknown Source)
> at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:138)
> ... 7 more
> 
The host is new for jsch or your ssh environment (known_hosts), so you 
have to trust it or pass the path to your known_hosts file to jasch

1) known_hosts
SftpFileSystemConfigBuilder.getInstance().setKnownHosts(opts, new 
File("path/to/known_hosts"));

2) or turn off the strictHostKeyChecking

FileSystemOptions opts = new FileSystemOptions();

SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, 
"no");
FileObject fo = VFS.getManager().resolveFile("sftp://xxxx", opts);

3) Or create a class which implememnts the
com.jcraft.jsch.UserInfo interface and configure it for your connection

SftpFileSystemConfigBuilder.getInstance().setUserInfo(opts, yourUserInfo);

That way you could implement a user-dialog where you ask the user to 
trust the host.


I hope one of the ways solves your problem.

---
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

		
---------------------------------
Do you Yahoo!?
 Yahoo! Small Business - Try our new resources site! 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message