atinux / node-ftps

FTP, FTPS and SFTP client for node.js, mainly a lftp wrapper.
MIT License
202 stars 57 forks source link

Fatal error: Host key verification failed. #59

Open Calvin92 opened 6 years ago

Calvin92 commented 6 years ago

Hi, I am confused about this error, can u spare some time to help me?

const FTPS = require('ftps')
const ftps = new FTPS({
    host: '192.168.xx.xx',
    username: 'xx',
    password: 'xx',
    protocol: 'sftp',
    port: 22,
})

ftps.cd('/export/wxsq/resource/fd/h5/for-fonts-server').addFile(__dirname + '/aa.css').exec(console.log);

Error:

null { error: 'cd: Fatal error: Host key verification failed.\r\nput: /Users/ruanjiawei/Desktop/ftptest/aa.css: Fatal error: Host key verification failed.\r\n',
  data: '' }
Calvin92 commented 6 years ago

Anything wrong with Host key ?

verils commented 6 years ago

I have this problem too. I don't understand why I can use lftp to connect sftp server directly with only my username & password, but just can't connect it when I run my node script without a ssh key?

hardy925 commented 6 years ago

@verils are you running the script on only your machine? are you able to $ ssh user@ip via terminal?

verils commented 6 years ago

@shardy613 I haven't tried to run that script on other machines yet. And, I can run $ ssh user@ip to connect server successfully, just the terminal gives me a hint:

The authenticity of host 'xxx' can't be established.
RSA key fingerprint is SHA256:xxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/xxx/.ssh/known_hosts).

I doesn't seem to make any effect.

hardy925 commented 6 years ago

Ok, you're inputting yes and getting the error? are you root on the machine? what os are you, this seems like a permission issue, Failed to add the host to the list of known hosts (/home/xxx/.ssh/known_hosts). The machine you are connecting to with the script should first be added to the known_hosts file.

verils commented 6 years ago

I use Windows7 for now, and run the terminal as admin.

I mean, when I input yes, though it gave me a hint like that, but it made no effect, I can still login into server.

I just tried ssh again and input no, and got Host key verification fail finally. Now I see, maybe running my script the low level functions answered a no automatically for me?And it just need a retry?:-) That's all I guess.

ufon commented 5 years ago

set 'autoConfirm: true' in config. that's helped me