Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.1k views
in Java FTP by (210 points)
I am getting below exception while connecting to SFTP server with public key.

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStream;

import com.enterprisedt.net.ftp.ssh.SSHFTPClient;

public class FtpFile {

public static void main(String[] args) {

InputStream privateKeyStream = null;

    try {

   

    File f = new File("/XX/yy/zz.asc");

    privateKeyStream = new FileInputStream(f);

    SSHFTPClient SFTP = new SSHFTPClient();

    SFTP.setRemoteHost("XXX");

    SFTP.setRemotePort(0);

    SFTP.setAuthentication(privateKeyStream, "XXX", "YYYY");

    SFTP.getValidator().setHostValidationEnabled(false);

   

    SFTP.connect();

    } catch (Exception e) {

    e.printStackTrace();

    } finally {

    if (privateKeyStream != null)

    try {

    privateKeyStream.close();

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

}

}

Exception : com.enterprisedt.net.j2ssh.transport.publickey.InvalidSshKeyException : Can't read key due to internal IO problems:

com.enterprisedt.net.j2ssh.transport.publickey.InvalidSshKeyException: Can't read key due to internal IO problems:

at com.enterprisedt.net.j2ssh.openssh.OpenSSHPrivateKeyFormat.decryptKeyblob(Unknown Source)

at com.enterprisedt.net.j2ssh.transport.publickey.SshPrivateKeyFile.toPrivateKey(Unknown Source)

at com.enterprisedt.net.ftp.ssh.SCPClient.setAuthentication(Unknown Source)
by (162k points)
Most likely zz.asc is not in a standard private key format. Try loading it in PuTTY.
by (210 points)
Then what are all the Key formats supported. Please list out.

Please log in or register to answer this question.

Categories

...