[VFS][SFTP] cannot connect to SFT server

classic Classic list List threaded Threaded
11 messages Options
lmk
Reply | Threaded
Open this post in threaded view
|

[VFS][SFTP] cannot connect to SFT server

lmk
Hi all,

I try vainly to use VFS to connect to SFTP server .
I do the same as explained on wiki page


here a snippet code

FileSystemManager fsManager =  VFS.getManager();
               
UserAuthenticator auth = new StaticUserAuthenticator(null, "login","passwd");
FileSystemOptions  ops = new FileSystemOptions();
try {

DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(ops,auth);

}
catch (FileSystemException ex) {
 throw new RuntimeException("setUserAuthenticator failed", ex);
 }

 FileObject fss = fsManager.resolveFile("sftp://x.x.x.x/export/home/",ops);



I get the exception:

Exception in thread "main" org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "sftp://x.x.x.x/".
        at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:99)
        at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:81)
        at org.apache.commons.vfs.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:62)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:641)
        at org.apache.commons.vfs.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:582)
        at com.fimat.kb.util.ftp.FTPManager.main(FTPManager.java:181)
Caused by: org.apache.commons.vfs.FileSystemException: Could not connect to SFTP server at "x.x.x.x".
        at org.apache.commons.vfs.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:214)
        at org.apache.commons.vfs.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:90)
        ... 5 more
Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: x.x.x.x
        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:210)
        ... 6 more

best regards!
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

Jörg Schaible
Well,

lmk wrote at Montag, 15. Dezember 2008 11:35:

>
> Hi all,
>
> I try vainly to use VFS to connect to SFTP server .
> I do the same as explained on
> http://wiki.apache.org/commons/SimpleSftpFileDownload wiki page

[snip]

> Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: x.x.x.x
> 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:210)
> ... 6 more

VFS cannot connect, since the underlaying library (JSch) cannot find the
host "x.x.x.x". Can you try again with the real host name instead of an IP
address?

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

lmk
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

lmk
I dont have a DNS server installed, the host cannot be found by name.

Jörg Schaible-2 wrote
Well,

lmk wrote at Montag, 15. Dezember 2008 11:35:

>
> Hi all,
>
> I try vainly to use VFS to connect to SFTP server .
> I do the same as explained on
> http://wiki.apache.org/commons/SimpleSftpFileDownload wiki page

[snip]

> Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: x.x.x.x
> 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:210)
> ... 6 more

VFS cannot connect, since the underlaying library (JSch) cannot find the
host "x.x.x.x". Can you try again with the real host name instead of an IP
address?

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

Jörg Schaible
lmk wrote at Montag, 15. Dezember 2008 14:20:

>
> I dont have a DNS server installed, the host cannot be found by name.

Well, you may temporarily add an entry to your local hosts file.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

lmk
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

lmk
how can I do that?


Jörg Schaible-2 wrote
lmk wrote at Montag, 15. Dezember 2008 14:20:

>
> I dont have a DNS server installed, the host cannot be found by name.

Well, you may temporarily add an entry to your local hosts file.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
lmk
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

lmk
Actually I have a host name defined on hosts file, but, I cannot ping it  however.
I can connect to SFTP server with Win SCP, I put the server ip address and it works ..




lmk wrote
how can I do that?


Jörg Schaible-2 wrote
lmk wrote at Montag, 15. Dezember 2008 14:20:

>
> I dont have a DNS server installed, the host cannot be found by name.

Well, you may temporarily add an entry to your local hosts file.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
lmk
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

lmk
In reply to this post by lmk
I passed to the last version of jcraft I get more explicit exception:

UnknownHostKey: x.x.x.x. RSA key fingerprint is 0d:51:c6:7f:e1:84:5e:37:8b:93:29:bd:d4:d1:ba:79

how can I verify the host key??





lmk wrote
I dont have a DNS server installed, the host cannot be found by name.

Jörg Schaible-2 wrote
Well,

lmk wrote at Montag, 15. Dezember 2008 11:35:

>
> Hi all,
>
> I try vainly to use VFS to connect to SFTP server .
> I do the same as explained on
> http://wiki.apache.org/commons/SimpleSftpFileDownload wiki page

[snip]

> Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: x.x.x.x
> 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:210)
> ... 6 more

VFS cannot connect, since the underlaying library (JSch) cannot find the
host "x.x.x.x". Can you try again with the real host name instead of an IP
address?

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
lmk
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

lmk
In reply to this post by lmk
I resolve the problem by adding

SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(ops, "no");

thanks..
Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

Jörg Schaible
In reply to this post by lmk
lmk wrote at Montag, 15. Dezember 2008 15:18:

>
> how can I do that?

http://en.wikipedia.org/wiki/Hosts_file

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

Jörg Schaible
In reply to this post by lmk
lmk wrote at Montag, 15. Dezember 2008 15:33:

>
> Actually I have a host name defined on hosts file, but, I cannot ping it
> however.

Well, that should be possible if the entry in the hosts file is correct and
the hosts file is in use.

> I can connect to SFTP server with Win SCP, I put the server ip address and
> it works ..

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [VFS][SFTP] cannot connect to SFT server

Jörg Schaible
In reply to this post by lmk
lmk wrote at Montag, 15. Dezember 2008 15:55:

>
> I passed to the last version of jcraft I get more explicit exception:
>
> UnknownHostKey: x.x.x.x. RSA key fingerprint is
> 0d:51:c6:7f:e1:84:5e:37:8b:93:29:bd:d4:d1:ba:79
>
> how can I verify the host key??

OK, this is really something different. Bascially it tells you, that is is
missing the fingerprint in the known_hosts file. Using the command line
you're normally asked on the first connect, wether the fingerprint is
correct or not and you have to confirm this by typing "yes".

The same applies more or less to all the Windows tools, but unfortunately
there's abolutely no standard where each tool writes its known_hosts file
and JSch has no idea where it should looking for it. However, the Sftp
connectot has a parameter ...

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]