Jacques44 / node-red-contrib-bigssh

remote command using ssh big node
Apache License 2.0
8 stars 12 forks source link

Credential file #1

Closed FredThx closed 8 years ago

FredThx commented 8 years ago

Hello, I don't understand how to make the credential file.

Please add more explaination in README

Thanks

Jacques44 commented 8 years ago

Hello, yeah, you're right. This node is the one I've so much doc to do...

Do you speak about the private key?

FredThx commented 8 years ago

Yes, my problem is about the private key.

Jacques44 commented 8 years ago

Hello, this node implements remote execution using ssh. It relies on https://www.npmjs.com/package/ssh2 and offers just a way to use this library. Do you have knowledge of how ssh works?

The credential key is used to authenticate users. To be able to use it, you need to generate keys (private and public) on the machine with node-red and give the public key to the remote host

How these keys are generated depend on whether you are using u*nix or Windows. On Unix, you should launch ssh-keygen to build the keys On Windows, you should use puttygen

Hope this helps

Regards

J.

FredThx commented 8 years ago

Hello,

Thank you the your reply.

I've just try this :

on the node-red machine : ssh-keygen -t dsa -b 1024 // with a passphrase ssh-copy-id -i ~/.ssh/id_dsa.pub my_login/my_server // with password for my_login/my_server

when I try ssh my_login/my_server It's works fine!

But when a use your node : host : my_server port : 22 username : my_login Private key path : /home/pi/.ssh/id_dsa // "pi" is my user

I get this message : Error: Encrypted private key detected, but no passphrase given

Note : if I don't use passphrase in the ssh-keygen command, the message is : Error: All configured authentication methods failed

Do you have an issue ?

Fred

Jacques44 commented 8 years ago

Hello I tried the same and had ssh work the same way on OSX. I've added passphrase support for the node. You need to npm update or npm install taking attention to your package.json if any

Regards

FredThx commented 8 years ago

Hello, I've updated the node. The passphrase is now ok. Thanks But I still have the error "All configured authentication methods failed".

I install ssh2 and test this code on a node console: var Client = require('ssh2').Client; var conn = new Client(); my_server = { host : '192..', port : 22, username : '.....', privateKey: require('fs').readFileSync('/home/pi/.ssh/id_dsa'), passphrase : '.....' }); conn.connect(my_server);

The command require('fs').readFileSync() success. But the conn.connect command failed :

conn.connect(config) undefined Error: All configured authentication methods failed at tryNextAuth (/home/pi/.node-red/node_modules/ssh2/lib/client.js:376:17) at SSH2Stream.onUSERAUTH_FAILURE (/home/pi/.node-red/node_modules/ssh2/lib/client.js:574:5) at emitTwo (events.js:87:13) at SSH2Stream.emit (events.js:172:7) at parsePacket (/home/pi/.node-red/node_modules/ssh2-streams/lib/ssh.js:3811:10) at SSH2Stream._transform (/home/pi/.node-red/node_modules/ssh2-streams/lib/ssh.js:649:13) at SSH2Stream.Transform._read (_stream_transform.js:167:10) at SSH2Stream._read (/home/pi/.node-red/node_modules/ssh2-streams/lib/ssh.js:236:15) at SSH2Stream.Transform._write (_stream_transform.js:155:12) at doWrite (_stream_writable.js:292:12)

Do you have an idea?

Fred

Jacques44 commented 8 years ago

hello, private/public key authentication needs strict rules:

  1. You need to add the incoming public key to the remote .ssh/authorized_keys file
  2. On both systems, the .ssh directory must be rwx for the user only. The authorized_keys must not be writable for group/else

J.

FredThx commented 8 years ago

Thanks for your answers.

the .ssh directory are rwx for the user only on both systems. and .ssh/authorizes_keys too.

And the command ssh remote_user@remote_ip work fine!

Jacques44 commented 8 years ago

Hello, yeah, I'm able to reproduce the problem with DSA type keys. I'm always using RSA with no problem

Still investigating

J.

Jacques44 commented 8 years ago

Hello, see: https://github.com/mscdex/ssh2/issues/428 It seems there is an issue with DSA. Can you try RSA?

Regards

J

FredThx commented 8 years ago

Ok, with RSA, it's working fine!!!

Thank you