theophilusx / ssh2-sftp-client

a client for SSH2 SFTP
Apache License 2.0
797 stars 195 forks source link

Error undefined symbol: EVP_CIPHER_CTX_get_iv_length in /sshcrypto.node #501

Closed InglisDav closed 9 months ago

InglisDav commented 9 months ago

Hello!

I migrate my code to Node 18 and update the library to "ssh2-sftp-client": "^7.2.1" but i'm getting an error when is processing this code:

const copyFileToRemote = fileName => {
    return new Promise((resolve, reject) => {
        try {
            console.log(`${fileName} - Trying to copy into remote.`)
            const sftp = new Client()
            const data = fs.createReadStream(`${localSourceDir}/${fileName}`)
            const remote = `${remoteDir}/${fileName}`
            sftp.on('keyboard-interactive',
            (name, instructions, instructionsLang, prompts, finish) => {
            finish([connectionSettings.password]); 
            });

            sftp.connect(connectionSettings)
                .then(() => sftp.put(data, remote))
                .then(() => {
                    console.log(`${fileName} - File successfully proccesed.`)
                    resolve(sftp.end())
                })
                .catch(err => reject(err.message),console.log("Error",err)                )
        } catch (err) {
            reject(err.message)
        }
    })
}

shows the log "${fileName} - Trying to copy into remote.`" but the log "${fileName} - File successfully proccesed" is never shown anymore and appears the error.

Error description: node: symbol lookup error: /app/node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node: undefined symbol: EVP_CIPHER_CTX_get_iv_length

I was investigating but apparently there is not much information about this error, I appreciate any comments that can help me.

theophilusx commented 9 months ago

I have not seen that error before. It looks like a local issue relating to the ssh2 installation. I would first try completely removing and re-installing your node_modules directory.

You need to upgrade to the latest version (v9.1.0). The version you are running is one of the first after the ssh2 re-write and is now over 2 years old. There have been a number of updates to ssh2 since then.

Do you really need the keyboard handler? It appears that you are passsing in the password as part of the connection options object. A keyboard handler is rarely required when working with sftp.

The error is from low level internal ssh2 code and nothing which I can help with from the ssh2-sftp-client level. If you need to investigate/debug this further, I would suggest writing a very simple ssh2 only script to transfer a file and see if you can reproduce the issue. If you can, you could then log an issue with the ssh2 project.