node-ftps icon indicating copy to clipboard operation
node-ftps copied to clipboard

Fatal error: Host key verification failed.

Open Calvin92 opened this issue 8 years ago • 7 comments

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 avatar Sep 30 '17 07:09 Calvin92

Anything wrong with Host key ?

Calvin92 avatar Sep 30 '17 07:09 Calvin92

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?

verils avatar Jan 31 '18 02:01 verils

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

hardy925 avatar Jan 31 '18 03:01 hardy925

@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.

verils avatar Jan 31 '18 03:01 verils

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.

hardy925 avatar Jan 31 '18 03:01 hardy925

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.

verils avatar Jan 31 '18 03:01 verils

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

ufon avatar Sep 21 '18 09:09 ufon