Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
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.setAuthentication(privateKeyStream, "XXX", "YYYY");




    } catch (Exception e) {


    } finally {

    if (privateKeyStream != null)

    try {


    } catch (IOException e) {






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 (158k 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.