Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.6k views
in Java FTP by (500 points)
when i do
sshftp.getValidator().addKnownHost("devlserv.cup.hp.com","/home/mohapatr/publickeyfile/file1.pub");

it gives me a
The host signature is invalid or the host key was not accepted!
ERROR

and

when i do
sshftp.getValidator().loadKnownHosts("/home/mohapatr/publickeyfile/file1.pub");

it gives me a
Bad Base64 input character at 10: 64(decimal)
ERROR.....

what do i do????which method shall i use????

anybody help me.............. :cry:

5 Answers

0 votes
by (162k points)
Please email us as attachments a log file set to ALL level (see the Dev Guide) and file1.pub. To support at enterprisedt dot com.
0 votes
by (500 points)
i am using webservices to connect to the sshftp,i have a sshftpclient class where i am implementing methods to establish the connection.

The piece of code is as follows:

sshftp = new SSHFTPClient( );


sshftp.setRemoteHost(props.getProperty("ftpMachine"));
sshftp.setRemotePort(22);
System.out.println("set a remote port");
// Turn off server validation (ONLY do this when testing)
sshftp.getValidator().setHostValidationEnabled(true);
String str = sshftp.getRemoteHost();
com.enterprisedt.net.ftp.ssh.SSHFTPPublicKey str1 = sshftp.getHostPublicKey(str);
System.out.println("host public key :" +str1);

sshftp.disableAllAlgorithms(SSHFTPAlgorithm.KEY_PAIR);

sshftp.setAlgorithmEnabled(SSHFTPAlgorithm.KEY_DSA, true);

System.out.println("get enabled algorithm :" +sshftp.getEnabledAlgorithms());

System.out.println("bit length :" +str1.getBitLength());
System.out.println("algorithm type :" +sshftp.getType());
sshftp.getValidator().addKnownHost("devlserv.cup.hp.com","/home/mohapatr/publickeyfile/file1.pub");

System.out.println("loading known hosts");

sshftp.setAuthentication("/home/mohapatr/publickeyfile/file1",props.getProperty("ftpUsername"),"Libra04");

System.out.println("authentication successful");



sshftp.setTimeout(60000); // "Gimme a minute!" hehe
// connect to the server
sshftp.connect();

When i run this through a client code which invokes the sshftpclient on the server side i get the ERROR!!! as

The host signature is invalid or the host key was not accepted!

on the server.

changing the addKnownHost() to
sshftp.getValidator().loadKnownHosts("/home/mohapatr/publickeyfile/file1.pub");

i get a ERROR!! as
Bad Base64 input character at 10: 64(decimal)
again on the server side....

This is a public key i generated using ssh-keygen

file1.pub:-

ssh-dss AAAAB3NzaC1kc3MAAACBAPjXY3x4W+VNi0w3FAMuJyfLYmxeL+S0MSauT7uw/HGZaKAoLu1i
ZLt3GAI3UaHroCb4cj6FB3QNA9vtelcSB1XwKWOvX1YCqbMh0NGYoWaE8I/8vUfVvvx/npARfRVgYAki
XKj/jB/R56TobaqMamHx0vcRFXjfy7Ot/eH6v+ozAAAAFQC0eEku2m7fjXo1kyNdHBqGpLhcNQAAAIAJ
3FguXRswHIzQ1X4i+yBiksZ6FLUyh84tTHfs70vWNz8A+TMGzik3dEfdWrmI6on4pamm3rbZCfYrZSwL
iHyC3JRsKm+XU+cjWYILv5WgIcAxmq8Pyl8QskEOKHmoXMrZPUa4+e3vq0oiZU1gAn4JjlYKUkaCZoCN
jeC6m6loxAAAAIBu9e+9t4A9nl63wArGxWxtJ7l5BmKOqGk4lnfvAGwjybpr0KeZnUjArMXbrAOgbDWU
M9dt0VewGGzVdQT9IcAcHa8M4lbR4cJEVKYu8FWpy8yzc1kc+rKUwtHnY0OTik/5PgEkoKri+nyff+V+
qfjjHu90m/a3MORZ9r1rBJKixg== SHARMISTHA@shell.sf.net



Anything else you require????

Kindly help me.....................
0 votes
by (162k points)
The correct method is addKnownHost("devlserv.cup.hp.com","/home/mohapatr/publickeyfile/file1.pub");

However, is this the public key of the server? If not, you will get the error you experienced. You can't just generate a public key - you need the public key belonging to the server you need to connect to.

You can use

sshftp.getValidator().setHostValidationEnabled(false);

to skip server validation initially.

Similarly, for sshftp.setAuthentication(), you need to supply your *private* key - but your public key must first be registered with the SSH server, otherwise public key authentication will not work.

You may want to start with password authentication first.

There's a lot of information in the Developer's Guide on these things.
0 votes
by (500 points)
i have already used

sshftp.getValidator().setHostValidationEnabled(false);

i get a perfect output through that.But knowing that it shows a low security if the validation is set false,I am implementing

sshftp.getValidator().setHostValidationEnabled(true);

does sshftp.getHostPublicKey(sshftp.getRemoteHost()); gives the public key of the server???

when i use this method it gives me

host public key :com.enterprisedt.net.ftp.ssh.SSHFTPPublicKey@b25494ad

as the output..........

Is this the one you were talking about???
And one more thing, where can i get the private key to set authentication using it???Any methods that may help me???

Please help me...........
0 votes
by (162k points)
sshftp.getHostPublicKey(hostname).write(new FileOutputstream("hostkey.pub"));

You can't "get" the private key, it is like a password. You need to generate a keypair, and register the public key for your user with the server (normally it is copied to a file called authorized_keys on the server - you may need to see your administrator). Then use the private key in setAuthentication().

Categories

...